Speed up development with full-stack environments for every branch.

Learn More

How to get selected option using jQuery

19635 Runs 113221 Views 51306 Copies
Saved

Saved

dipesh.parmar 55

dipesh.parmar
published 4 years ago

    /* 
      jQuery ready function. Specify a function to 
      execute when the DOM is fully loaded.
    */
    $(document).ready( function ()
    {
      /* we are assigning change event handler for select box */
    	/* it will run when selectbox options are changed */
    	$('#dropdown_selector').change(function()
    	{
    		/* setting currently changed option value to option variable */
    		var option = $(this).find('option:selected').val();
    		/* setting input box value to selected option value */
    		$('#showoption').val(option);
    	});
    });
    
    Please login/signup to get access to the terminal.

    Your session has timed out.

    Dismiss (the page may not function properly).