Reputation: 11812
I have couple of select box and I would like to know which select box is triggered.
Html code:
<form id="property-filters" method="post">
<select name="sel1">
<option value="1">1</option>
<option value="2">2</option>
</select>
<select name="sel2">
<option value="3">3</option>
<option value="4">4</option>
</select>
</form>
Jquery code:
$(document).on('change', '#property-filters input, #property-filters select', function ()
{
//Get the name of the select box.
}
Any help is highly appreciated. Thanks in advance.
Upvotes: 1
Views: 113
Reputation: 28741
You can do
$('#property-filters select').change(function () {
alert($(this).prop('name'));
});
Check JSFiddle
Upvotes: 0
Reputation: 115222
Check the name property of the event fired dom object.
$(document).on('change', '#property-filters input, #property-filters select',function () {
if(this.name == 'sel1'){
// do the rest
}else if(this.name == 'sel2'){
// do the rest
}
})
Upvotes: 2