{"id":1702,"date":"2022-08-30T15:18:44","date_gmt":"2022-08-30T15:18:44","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/29\/jquery-html-not-not-working-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:18:44","modified_gmt":"2022-08-30T15:18:44","slug":"jquery-html-not-not-working-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/jquery-html-not-not-working-collection-of-common-programming-errors\/","title":{"rendered":"Jquery html() not not working-Collection of common programming errors"},"content":{"rendered":"<p>I have a simple js function:<\/p>\n<pre><code> function changeContent(id, content) {\n         $(id).html(content);\n     }\n<\/code><\/pre>\n<p>which gets called on ajax callback. id is an id of a div, and $(id) does indeed find it.<\/p>\n<p>On Chrome I get an unhandled exception that HTMLDivElement doesn&#8217;t contain method html(), while on IE8 and FF simply nothing happens, although when viewing in degub, .html() does appear in the dynamic method list.<\/p>\n<p>What am I doing wrong?<\/p>\n<p>EDIT: No, I&#8217;m not passing the id with #. I&#8217;ve tried that, it returned null, now it actually returns something. Is there another problem??<\/p>\n<p>EDIT again: seems I was doing something else wrong. I&#8217;ve put the # back, now it works.<\/p>\n<ol>\n<li>\n<p>Try use jQuery(id) instead.<\/p>\n<p>You are sure you don\u00b4t pass the id without &#8220;#&#8221; right?<\/p>\n<\/li>\n<li>\n<p>Are you passing simply the ID as a string? In which case I would think it&#8217;s not truly being found, maybe try this?<\/p>\n<pre><code> function changeContent(id, content) {\n         $('#'+id).html(content);\n     }\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-29 06:07:16. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have a simple js function: function changeContent(id, content) { $(id).html(content); } which gets called on ajax callback. id is an id of a div, and $(id) does indeed find it. On Chrome I get an unhandled exception that HTMLDivElement doesn&#8217;t contain method html(), while on IE8 and FF simply nothing happens, although when viewing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1702","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1702"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1702\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}