I’m writing a personal plugin, and it needs to do an action when it hovers over a specific element. I’m running console.log($(this)); and console.log($this); (I have var $this = $(this) before I declare my default options.
Anyways, when logging that stuff out to the console, I just get an object with the Node information, i.e. <li id="some_id_here"></li>, but none of the text within that <li> (there is text inside of it, as well as a <span>...</span>.
Can anybody help me here? Not sure what I need to do to grab the actual text of the <li>…
Thank you!
Note: It was indeed the case of me assigning $this = $(this). Once I adjusted the nomenclature, it all fell into place. Thanks for your help!
If you have $this = $(this); then you can simply do:
So you could try:
For furthermore reading, take a look to jQuery .html() and .text() methods documentation here.
Cheers!