Dave's Brain

Browse - programming tips - jquery fire select change event

Date: 2010jul7
Platform: jQuery
Language: javaScript

Q.  How simulate a user changing their choice for a <select> in jQuery?

A.  This is only useful if you have a function to that reacts.

	// make your function mySelectChanged() execute when the user
	// changes the <select>
	$('.myselect').change(mySelectChanged);
	
	// Later in the code, whenever you want it do this
	// to simulate the user making the change. Your function will execute.
	$('.myselect').trigger('change');
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: