troubleshooting Question

Get the text of selected option when changes

Avatar of MrKevorkian
MrKevorkian asked on
JavaScriptHTML
10 Comments2 Solutions356 ViewsLast Modified:
hi,

I have the following select

<div class="availableResourcesDiv">
<select  id="availableResources">
<option value="-1">None selected</option>
<option value="123">Philip Smith</option>
<option value="456">Ian Smith</option>
</select>
    </div>


I am capturing the selection like this:

  $(".myDiv").change(function () {


});

If the user selects "Philip Smith" how can I grab that name text from within my change event.

$(this).Text()  - just gives me the text of all the options.

So I need something like this!

$(".myDiv").change(function () {  

$(this).TextForSelectedOption()

});

thanks
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros