javascript - Setting and getting value of select with jQuery -


i have question setting value of select drop down jquery

i've written code

// should find option want , set selected jquery('[name=' + obj.name + ']').val(obj.value)      .find("option[value=" + obj.value + "]").attr('selected', true);  // should set value of select same above jquery('[name=' + obj.name + ']').val(obj.value); 

providing obj.name = "selmanufacturer" , obj.value of option values of below select, have problem:

the first piece of code seem work. can see option selected. when want .val() of select empty string. idea why?

<select style="display:none;" class="js-manufacturerlist" name="selmanufacturer" id="manufacturerlist">     <option value=""></option>     <option selected="selected" value="apple">apple</option>     <option value="microsoft">microsoft</option>     <option value="hp">hp</option> </select> 

when

jquery("#manufacturerlist").val() // "" jquery("#manufacturerlist option:selected").val() // "" jquery("#manufacturerlist").find(":selected").text() // "" 

this happens in firefox


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -