{"id":2242,"date":"2019-10-18T08:53:10","date_gmt":"2019-10-18T07:53:10","guid":{"rendered":"https:\/\/ibex.tech\/javascript\/?p=2242"},"modified":"2022-02-17T07:14:46","modified_gmt":"2022-02-17T07:14:46","slug":"adding-onclick-functionality-to-an-html-element","status":"publish","type":"post","link":"https:\/\/ibex.tech\/javascript\/manipulating-html\/adding-onclick-functionality-to-an-html-element","title":{"rendered":"Adding onclick functionality to an html element"},"content":{"rendered":"\n<p>Use this in the page footer (after the element to be changed)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script>\n  document.getElementById( 'user-xprofile' ).onclick = function() { MyFunction(); };\n&lt;\/script><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Change the html content and add an on click submit form to a span<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script>\n  document.getElementById( 'ajax_value1' ).innerHTML = 'Click here...';\n  document.getElementById( 'ajax_value1' ).onclick = function(){document.getElementById( 'my_form_id' ).submit();};\n&lt;\/script><\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use this in the page footer (after the element to be changed) Change the html content and add an on click submit form to a span<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74],"tags":[],"class_list":["post-2242","post","type-post","status-publish","format-standard","hentry","category-manipulating-html"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/2242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/comments?post=2242"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/2242\/revisions"}],"predecessor-version":[{"id":2817,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/2242\/revisions\/2817"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/media?parent=2242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/categories?post=2242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/tags?post=2242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}