Wednesday, May 29, 2019

javascript - How do I check whether a checkbox is checked in jQuery?

I need to check the checked property of a checkbox and perform an action based on the checked property using jQuery.



For example, if the age checkbox is checked, then I need to show a textbox to enter age, else hide the textbox.



But the following code returns false by default:





if ($('#isAgeSelected').attr('checked'))
{

$("#txtAge").show();
}
else
{
$("#txtAge").hide();
}











How do I successfully query the checked property?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...