I'm trying to check the "Select All" box, but when I uncheck it and select it again, it will no longer select the fields. Although it works for the first time.
This is my code:
HTML:
<div id="Everything"> <input type="checkbox" id="all" />Select All <br /> <br /> <div id="selectThese"> <input type="checkbox" id="First" />First <br /> <input type="checkbox" id="Second" />Second <br /> </div> </div>
JS:
$(function () { $("#Everything").on("click", "#all", function () { var carStatus = $("#all").is(':checked'); if (carStatus == true) { $("#selectThese input").attr("checked", "checked"); } else { $("#selectThese input").removeAttr("checked"); } }); });
Jsfiddle Link: http://jsfiddle.net/Epsju/1/
user1646859
source share