I am trying to uncheck an input
item within each list item, where the li
is currently checked
and hidden
.
DEMO http://jsfiddle.net/VHW9U/
$('#mylist input:checked').each(function() {
if(!$(this).is(":visible")){
$(this).find("input:checkbox").prop("checked", false);
}
});
The above code does not work, i have tried various different approaches and none of them seem to work. If you view the source code of the jsfiddle you will see that the hidden inputs
are still checked
Try this, the checkboxes aren't inside checkboxes. $(this).find("input:checkbox")
. this
is the checkbox
$('#mylist input:checked').each(function() {
if(!$(this).is(":visible")){
$(this).prop("checked", false);
}
});
Note This will not change the attribute checked, but the property. DEMO
Try
$('#mylist li:hidden input:checked').prop("checked", false);
$('#mylist li:hidden input:checked')
get checked
input
inside the hidden li
which inside element with id mylist
$('#mylist input:checked:hidden').prop("checked", false);
$('#mylist input:checked:hidden')
get checked
input
inside element with id mylist
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.