I’ve “cached” a jQuery object that I use inside a loop called $myElement. I would like to use some native JavaScript functions on it (for better performance). However, my attempts below throws errors (the element is undefined). Is there any way to accomplish this?
$myElement.find('span')[0];
$myElement.find('span').get(0);
Update: What Im trying to do is something like:
$myElement.find('span')[0].innerHTML('some text');
That’s giving me an error.
You seem to need
Because innerHTML isn’t a function on basic DOM elements.
But there is nothing wrong, if you get your element using jQuery, to also use the html function :
I don’t think you’re optimizing at the right point.