JQuery in console not working properly

I am using the jQueryify bookmarklet on the page so that I can call jQuery functions from the console. But every time I call the jQuery function on the selected object, I get an error:

"TypeError: jQuery("li")[0].children[0].html is not a function
[Break On This Error] jQuery('li')[0].children[0].html();

I tried this in FireBug as well as in the Google Chrome Webkit console.

+5
source share
5 answers

You no longer work with jQuery objects using square brackets.

jQuery("li")[0]

This returns 1st lias a DOMElement, not a jQuery object.

jQuery("li")[0].children[0]

This returns the 1st li1st child as a DOMElement, not a jQuery object.

.html()

This function only works for jQuery objects. For DOMElements you can use a property .innerHTML.

DOMElements, jQuery. :

jQuery('li').eq(0).children().eq(0).html()
+9

, jQuery, html, DOM children[0]. jQuery, html

var temp = jQuery("li")[0].children[0];
var html = jQuery(temp).html();
+5

jQuery("li")[0].children[0], DOM, jQuery. HTML ,

jQuery(jQuery('li')[0].children[0]).html();

DOM jQuery, .html().

+5

jQuery(jQuery("li")[0].children[0]).html();

jQuery("li:eq(0)").children(':eq(0)').html();

jQuery("li:eq(0)").children().eq(0).html();

jQuery("li").eq(0).children().eq(0).html();
+3

jquery ( []) DOMElement, , , jquery. , eq().

+3

All Articles