I have variable that get’s value of checked radio button named: parentcheck
I wanna check if parentcheck is checked and =0 or if not checked. Tried if(parentcheck==”) for “not checked”. it doesn’t work.
var parentcheck = $(".parentcheck:checked").val();
if(parentcheck=='0'){
$("#parent").hide();
}
if(parentcheck==''){
$("#parent").hide();
}
First off, that selector you use will only return you elements with the class
.parentcheckwhich are actually checked. By definition, that means every element it returns (as it always returns a set in jQuery) will be checked, so if the element you’re looking for isn’t checked then it won’t be in the set. Something like this might be what you’re after: