javascript - JQuery to put select option text into an input -


i using code here, pulls out selected option value drop-down box named "attribute[466]" puts value input field id of text_qty_

jquery(function($){    var $idval = $('#text_qty_');    $('select[name="attribute[466]"]').change(function(){       $idval.val($(this).val())    }).triggerhandler('change') }); 

what can't figure out how text option selected rather value.

as added challenge select element contains drop-down box has randomly generated id attribute.

find selected option , read text

var txt = $(this).find('option:selected').text(); 

jsfiddle


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -