I have html items, 4 example:
<div>
<div><input type="checkbox" class="foo"> Checkbox</div>
<div><input type="checkbox" class="foo"> Checkbox</div>
<div><input type="checkbox" class="foo"> Checkbox</div>
<div><input type="checkbox" class="foo"> Checkbox</div>
<div><input type="checkbox" class="foo"> Checkbox</div>
<div><input type="checkbox" class="foo"> Checkbox</div>
</div>
And now, I want next: If I click on any checkbox – the checkbox should be checked and other checkboxes should be unchecked. How can I do it?
You can use
radiobutton and group them by name attributes. If you have to do it withcheckboxesthen you can do it this way,Live Demo
For dynamically generated html you need on that allows you to delegate the event with static parent, you can use document with you do not know static parent.
Document could be replaced by static parent if it is known. e.g. if div contain dynamically generated has id
parentdivthen you can haveEdit
Use
propinstead ofattrfor propertieschecked,selected, ordisabledas per documentation.