How do I specify label to Checkbox that is added thru the JQuery Clone(false) method and does not have a Unique id ?
+1
A:
The label needs something to link it with the checkbox. Hence, you need to add a unique ID to the checkbox and use this to relate the label.
I'd use something to count the number of checkboxes, increment this count and use it to ensure your ID is unique.
var checkCount = $("input[type='checkbox']").length;
var newCheckbox = $(oldCheckBoxID).clone(false).attr("id", "checkbox" + checkCount);
var newLabel = $("<label />").attr("for", "checkbox" + checkCount).html("label text");
daddywoodland
2009-09-02 12:52:06