I have a common event handler for my select buttons :
My code is :
$(document).ready(function(){$("#delAppSelectApp,#userAppSelectApp,#hexSelectApp,#countSelectApp").change(function(){
......
});});
How would I call an additional function if changing “countSelectApp” select triggered the
common handler.
I tried using
alert(this.toSource())
to ascertain which select triggered the handler, but all I get is an alert saying
[object HTMLelement]
Within your event handler jQuery sets
thisto be the DOM element that the event applies to, so you can directly access any properties or methods apply to DOM events, or you can wrap it in a jQuery call as$(this)to access jQuery methods.So in my opinion the simplest (and certainly most efficient) way to test whether it was “countSelectApp” that the event applied to is just to use
this.id:Incidentally, rather than list all the element ids in your jQuery selector I’d be inclined to give those elements a common class, say “selectApp”, and then bind the change handler using class as a selector: