开发者

change/modify the dropdownlist text by value using jquery

开发者 https://www.devze.com 2022-12-15 13:38 出处:网络
i have dropdownlist with th开发者_运维问答e values: <select id=\"myddl\" name=\"myddl\"> <option value=\"1\">One</option>

i have dropdownlist with th开发者_运维问答e values:

<select id="myddl" name="myddl">
  <option value="1">One</option>
  <option value="2">Twooo</option>
  <option value="3">Three</option>
</select>

I need to change the text Twooo to Two using the value of the dropdownlist option(2). How can i do it in jquery?


$('#myddl option[value=2]').text('Two');


var myDLLField = $('select[id="myddl"]');
myDLLField.find('option[value="2"]').text("Two");   

or, in one line...

$('select[id="myddl"]').find('option[value="2"]').text("Two");  
0

精彩评论

暂无评论...
验证码 换一张
取 消