0

I have written a javascript/jquery function to retrieve the selected dropdown value. The page is running well in chrome but when i run my application in IE it throw an error.

$("#Application_AppCountries").change(function () {

        var selectedOption = $(this)[0].selectedOptions[0]; //THrow an error on this line
        var text = selectedOption.text;
        var value = selectedOption.value;

    });

And HTML code is:

<div>
@Html.LabelFor(m => m.Application.AppCountries, "Primary Country")<span class="required">*</span>
                                @Html.DropDownListFor(m => m.Application.AppCountries, Model.Countries)
</div>

Any help or suggestion will be highly appreciated.

user3179537
  • 23
  • 1
  • 1
  • 10
  • It means that there's no property named `selectedOptions` on the element. Internet Explorer doesn't support that. – Pointy Dec 03 '15 at 16:25
  • Please show the actual HTML (what the browser sees), not the version in some template language that is then turned into real HTML. You can get the real HTML with View/Source in the browser while viewing that page. Specifically we need to see what type of HTML element #Application_AppCountries is. – jfriend00 Dec 03 '15 at 16:26

1 Answers1

1

Try this:

var selectedOption = $(this).find(':selected');

Similar question: jQuery Get Selected Option From Dropdown

Community
  • 1
  • 1
AVProgrammer
  • 1,344
  • 2
  • 20
  • 40