如何检查一个复选框是否在 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?

转载于:https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery

查看全部
csdnceshi57
perhaps?
2009/05/23 15:16
  • dom
  • html5
  • checkbox
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

0个回复