Get the text <select> using the 'this' keyword

I am using the following code:

<select class="element select medium" id="inDistrict" name="inDistrict" onchange="setCookie('lastvalue',this.value,1);"> 

Does not accept: this.value. What else do you need to use to get selected DropDown text?

+4
source share
2 answers
 var i = this.selectedIndex; var selectedText = this.options[i].text; 

Gotta do it (if that's the right context).

+2
source

All Articles