所以我有一组标签都属于"btn btn-warning"bootstrap类:
<div class = "btn-group" data-toggle = "buttons">
<label class="btn btn-warning active">
<input type="radio" checked>QA 71</input>
</label>
<label class="btn btn-warning">
<input type="radio">QA 72</input>
</label>
<label class="btn btn-warning">
<input type="radio">QA 73</input>
</label>
<label class="btn btn-warning">
<input type="radio">QA 74</input>
</label>
<label class="btn btn-warning">
<input type="radio">ST 71</input>
</label>
<label class="btn btn-warning">
<input type="radio">PR/Beta</input>
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
我想为所有人分配ID,其中一个标记为QA 71 environment1,下一个标记为environment2,等等.这是我的jquery函数:
var count = 1;
var btnid = "";
$(document).ready(function(){
$("label .btn-warning").each(
function(){
btnid = "environment"+count;
$(this).attr("id", btnid);
count++;
});
});
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用.我究竟做错了什么?