Reputation: 2509
I am able to get the selected value of a dynamic dropdown using the below code
$("span[id*="+ orgId +"]")[0].innerHTML=$("'input[id$=" + comanyDropDown+ "]:'selected").val();
I want the retriev the selcted text for which i used
$("span[id*="+ orgId +"]")[0].innerHTML=$("'input[id$=" + comanyDropDown+ "]:'selected").text();
But it will retrieve all the items of the dropdown.
I tried with
$("span[id*="+ orgId +"]")[0].innerHTML=$("'input[id$=" + comanyDropDown+ "]:option:'selected").text();
How to get the selected text of dynamic dropdown.
Upvotes: 0
Views: 1203
Reputation: 144659
Your selector is wrong. There is no :option
selector, also you trying to filter an input element which is an option, surely your selector doesn't find such element. Try the following:
$("span[id*="+ orgId +"]")
.html( $("option[id$=" + comanyTextBox + "]:selected").text() );
Upvotes: 1