[Special Summer Sale] 40% OFF All Magento 2 Themes

Cart

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

  • This topic is empty.
Viewing 31 post (of 31 total)
  • Author
    Posts
  • #9008
    David Hoang
    Keymaster

    You could try the followings in both ways:

    var getVal=$('#isAgeSelected').is(":checked"); // jQuery
    
    var getVal=document.getElementById("isAgeSelected").checked //JavaScript
    
    if (getVal==true) {
     $("#txtAge").show();  // checked
    } else {
     $("#txtAge").hide();  // unchecked
    }
    
Viewing 31 post (of 31 total)
  • You must be logged in to reply to this topic.