How would I return Some Text, <a href="abc.html">Some Anchor</a>, and <img src="abc.jpg" /> from the following three elements without using jQuery? In other words, how would I return $('#t1).text(), $('#t2).text(), $('#t3).text() without using jQuery? I don't need to return an array if multiple elements as I will only select one element at a time.
<td id="t1">Some Text</td>
<td id="t2"><a href="abc.html">Some Anchor</a></td>
<td id="t3"><img src="abc.jpg" /><td>
jQuery does text() as follows. It seems overkill since I am not worried about returning an array for multiple elements.
text: function( value ) {
return jQuery.access( this, function( value ) {
return value === undefined ?
jQuery.text( this ) :
this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
}, null, value, arguments.length );
},
Thanks
$('#t2')would returnSome Anchor, not<a href.... Same for$('#t3').innerHTMLproperty after usingdocument.getElementById()?<a>a <b>b</b> c</a>and retrievea b c?