{"id":10996904,"date":"2018-12-17T08:35:49","date_gmt":"2018-12-17T08:35:49","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/javascript-not-added\/"},"modified":"2018-12-17T08:35:49","modified_gmt":"2018-12-17T08:35:49","slug":"javascript-not-added","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/javascript-not-added\/","title":{"rendered":"JavaScript not added"},"content":{"rendered":"<p>Hi,<br \/>\nI added this simple code to a WordPress post:<br \/>\n<code>&lt;button type=&quot;button&quot; onClick=&quot;doSomething()&quot;&gt;Do Something&lt;\/button&gt;<\/code><\/p>\n<p>and in the <\/p>\n<blockquote><p>This code will be included verbatim in &lt;script&gt; tags at the end of your page&#8217;s (or post&#8217;s) &#8230;<\/p><\/blockquote>\n<p> form I added the following code:<\/p>\n<pre><code>function doSomething() {\n\tconsole.log(&#039;called&#039;)\n}<\/code><\/pre>\n<p>I click <code>Update Scripts<\/code> and then <code>Preview<\/code>. In the preview page however, if I click the button, nothing happens, and the console shows: <code>ReferenceError: doSomething is not defined<\/code>. In fact, it turns out that my code is not present in the page. I&#8217;m using the Independent Publisher 2 theme. What could be the problem?<\/p>\n","protected":false},"template":"","class_list":["post-10996904","topic","type-topic","status-publish","hentry","topic-tag-post","topic-tag-referenceerror"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10996904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10996904\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=10996904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}