javascript - Select option get value by text using JQUERY -
this question has answer here:
- $(“select>option[text='xxx']”) not work 3 answers
i have html select (dropdown) many populated options. have table many names button next it. need when press button next name name selected in select box(dropdown). option value id , option text name. example:
!nameslist!v! <- select box john !button! tom !button! laura !button!
i have tried use:
var name = "john"; $("#cmboperator option[value='" + name + "']").attr('selected', 'selected');
but doesn't work. if change var name id(which value) works. how can option's value text?
$("select option:contains(text)").attr('selected', true);
here jsfiddle
Comments
Post a Comment