Please see coments in js code.
I have two checkboxes
<input type="checkbox" name="first" id="first" />
<input type="checkbox" name="second" id="second" />
Here is my 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 ?
/*
}
});
});
You just want to use
.notto filter out the currently clicked item (this)http://jsfiddle.net/infernalbadger/amz7f/