So habe ich eine Gruppe von Etiketten, die die „btn btn-Warnung“ Bootstrap-Klasse gehören alle zu:alle Elemente einer Klasse eindeutigen IDs in JQuery zuweisen
<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>
Ich mag würde IDs alle zuweisen sie, mit dem ein QA etikettiert 71 als environment1
, die nächste wie environment2
usw. Hier ist meine jquery-Funktion:
var count = 1;
var btnid = "";
$(document).ready(function(){
$("label .btn-warning").each(
function(){
btnid = "environment"+count;
$(this).attr("id", btnid);
count++;
});
});
dies ist jedoch nicht funktioniert. Was mache ich falsch?
Sollte sein 'label.btn-warning', kein Platz. –