I have a easy select tag:
<select>
<option></option>
<option></option>
</select>
Then I want use jQuery get the option’s content:
var s=$('select option');
for(var i=0;i<s.length;i++){
console.log(s[i]);
}
it would only show "<option>",without the content.
If I use console.log(s[i].html());, it would tell me it is wrong.
So how can I get the content?
You don’t need jQuery to get the text content.
An
HTMLOptionElementhas a.textproperty.Although if you want the
.outerHTMLof the element (a little confused by your question), you could do this……though this only recently became available in Firefox, so you could create a method to patch it…
…and use it like this…