Wednesday, February 7, 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)
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...
-
When the left part is an object instance, you use -> . Otherwise, you use :: . This means that -> is mostly used to access instance m...
-
This question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programm...
-
I am new to dask and I found so nice to have a module that makes it easy to get parallelization. I am working on a project where I was able ...
No comments:
Post a Comment