Onclick Get This TextContent Of An Element
- first node textContent
- textContent1
Solution 1:
use text()
:
$(document).on("click", ".myclass ul li", function() {
var txt = $('i', this).length ? $('i', this).text() : $(this).text();
alert( txt );
});
Also, live()
has been deprecated and removed, and to get the text of the i element if such an element exists, you check if exists and the act appropriately
Post a Comment for "Onclick Get This TextContent Of An Element"