Skip to content
Advertisement

correct way to get selected option in jquery from an object

I’ve seen on StackOverflow and googling around that the most used way to get the selected text from a <SELECT> element with jquery is like this

JavaScript

what I have is not the id, but an object. I have an object, say

JavaScript

coming from an earlier piece of code.

I’ve done like this to get the selected text, but is ugly:

JavaScript

Is there any cleaner way to do it?

Advertisement

Answer

JavaScript
Advertisement