Created
October 18, 2013 01:56
-
-
Save springcome/7035321 to your computer and use it in GitHub Desktop.
checkbox, jquery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="checkbox" name="chk" id="chk1" value="1" />1번 | |
<input type="checkbox" name="chk" id="chk2" value="2" />2번 | |
<input type="checkbox" name="chk" id="chk3" value="3" />3번 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// checkbox checked여부확인 | |
console.log($('#chk1').is(':checked')); | |
$(':input[name=chk]').each(function(){ | |
if($(this).is(':checked')){ | |
console.log('true'); | |
}else{ | |
console.log('false'); | |
} | |
}); | |
// value를 가지고 checked하고자 할때 | |
$(':input:checkbox[name=chk][value=2]').attr('checked', true); | |
// checked되어 있는 모든 checkbox를 알고자 할때 | |
$(':input:checkbox[name=chk]:checked').each(function(){ | |
console.log($(this).val() + " : " + this.id); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment