You don't need jQuery to get the text content.
An HTMLOptionElement
has a .text
property.
var s = $('select option');
for(var i = 0; i < s.length; i++) {
console.log(s[i].text);
}
Although if you want the .outerHTML
of the element (a little confused by your question), you could do this...
var s = $('select option');
for(var i = 0; i < s.length; i++) {
console.log(s[i].outerHTML);
}
...though this only recently became available in Firefox, so you could create a method to patch it...
function outerHTML(el) {
return el.outerHTML || document.createElement('div')
.appendChild(el.cloneNode(true))
.parentNode
.innerHTML;
}
...and use it like this...
var s = $('select option');
for(var i = 0; i < s.length; i++) {
console.log(outerHTML(s[i]));
}