Basic jquery question. I have an option element as below.
To match the title of this question, the value of the id attribute is:
var myId = $(this).attr('id');
alert( myId );
BUT, of course, the element must already have the id element defined, as:
In the OP post, this was not the case.
Note that plain js is faster (in this case):
var myId = this.id
alert( myId );
That is, if you are just storing the returned text into a variable as in the above example. No need for jQuery's wonderfulness here.