How To Dynamically Laid Upwards Direct Alternative Selected Using Jquery?

I accept a choose champaign amongst around options inward it as well as desire to choose a specific choice of a choose tag dynamically:
The choose List equally follows:
<select id="my_val">       <option value="1">Red</option>       <option value="2">Green</option>       <option value="3">Blue</option> </select> 

You tin mail away solve the inward a higher house work using next pocket-sized slice of jquery function.
 $(document).on('change', '#my_val', function(e) {         e.preventDefault();      var option_val = $("#my_val").val(); //store the dynamic value of choose choice       $( "#my_val" ).find( 'option[value="' + option_val + '"]' ).prop( "selected", truthful ); //Set choose choice 'Selected'                                     }); 
There may live on many other possible solutions. Above 1 worked best for me.
Sumber http://developer-paradize.blogspot.com

Comments

Popular posts from this blog

What Are The Main Components of a Computer System

Top Qualities To Look For In An IT Support Team

How To Integrate Google Adwords Api Into Codeigniter?