Reputation: 10395
I want run some code on each select
on page load and re-run it by some events on each select
separately. currently done with following:
jquery(function(){
$('#myID select').each(function(){
alert('SE');
});
$('#myID select').bind('keyup keypress blur change',function(){
alert('SE');
});
});
Can I merge them into one?
Upvotes: 1
Views: 84
Reputation: 145398
You may trigger one of the events on DOM ready:
$(function() {
$("#myID select").bind("keyup keypress blur change", function() {
alert("SE");
}).keyup(); // or .trigger("keyup");
});
Upvotes: 3