js 코드의 coments를 참조하십시오. 당신은 단지 현재 클릭 항목을 필터링 .not
를 사용하려면다른 체크 상자를 찾으십시오
$('input[type=checkbox]').click(function() {
/*
HERE i want to manipulate the checkbox which is not clicked
NOTICE: they are only two checkboxes in page
I know that I can do something like this
if($(this).attr('id') == "first) {
do something
} else {
etc...
}
But I think that way is against DNRY
Can you recommend me some more elegenat solution ?
*/
//you can get the other checkbox by filtering out the element you clicked
//in this case i hide it
$('input:checkbox').not(this).hide();
});