Wednesday, 7 February 2018
javascript - checking if a checkbox is checked?
Answer
Answer
How can I check if a checkbox is checked via jQuery?
Can I just add an ID or class to the element and do this?
if($('#element').val() == 1) {
//do stuff
}
Answer
if($('#element').is(':checked')){
//checkbox is checked
}
or
if($('#element:checked').length > 0){
//checkbox is checked
}
or in jQuery 1.6+:
if($('#element:checked').prop('checked') === true){
//checkbox is checked
}
Subscribe to:
Post Comments (Atom)
casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV
In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...
-
I'm using Simple HTML DOM to extract data from a HTML document, and I have a couple of issues that I need some help with. On the line th...
-
How I write a function "noVowel" in python that determines whether a word has no vowels? In my case, "y" is not a vowel....
-
Basically I am from C, Embedded C field. After working for 5 yrs in this field, I would like to start C++. Now, I have started learning C+...
No comments:
Post a Comment