Reputation: 1489
I have an indepth complicated set of jquery code, which is triggered with
$(basketUpdateTrigger).click(function() {...
What I need to do is trigger the same set of code when $('select').change
happens - that is, when the selected option of a dropdoan box is changed.
I looked at .bind() but that just does not seem to answer the problem.
Upvotes: 0
Views: 34
Reputation: 891
u can use bind method to attach an eventhandler
$('#btn').bind('click', function() { // TO DO } );
Upvotes: 0
Reputation: 272046
You can manually invoke the click handler when the select element changes:
$("select").on("change", function() {
$(basketUpdateTrigger).trigger("click");
});
Alternately, you can wrap the logic inside a named function; then assign that function to click and change event handlers.
Upvotes: 3