2014年12月23日 星期二

[jQuery] Find selected option with "this"

Usually, when we want to get the selected option's text using jQuery, we will use the following method.

var selVal = $("selObj#selID option:selected").val()

What if the target object is "this"? We will instead use the following

var selVal = $("option:selected", this).prop("value");

沒有留言:

張貼留言