Reputation: 145
whether or not my variable "showforfamilymember" has a value of true or false it always the show checkbox as checked
<label for="showforfamilymemberchk">Show This Group While Adding Family Member</label>
<input type="checkbox" name="showforfamilymemberchk" id="showforfamilymemberchk" />
jQuery
var txtshowforfamilymember = $("#showforfamilymemberchk");
txtshowforfamilymember.attr("checked", showforfamilymember);
Upvotes: 0
Views: 25
Reputation: 695
How are you setting showforfamilymember ?
If you do it like this it should work
var showforfamilymember = false;
if you have the value stored let's say in some string "myValue"
var showforfamilymember = (myValue.toLowerCase() === 'true');
Hope it works
Upvotes: 1
Reputation: 752
Try using .prop() instead of .attr()
txtshowforfamilymember.prop("checked", showforfamilymember);
Upvotes: 1