請在js代碼中查看評論。查找其他的複選框
我有兩個複選框
<input type="checkbox" name="first" id="first" />
<input type="checkbox" name="second" id="second" />
這裏是我的javascript
$(function() {
$('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 ?
/*
}
});
});