{"id":3689,"date":"2021-02-25T11:43:05","date_gmt":"2021-02-25T11:43:05","guid":{"rendered":"https:\/\/ibex.tech\/javascript\/?p=3689"},"modified":"2022-02-17T07:14:46","modified_gmt":"2022-02-17T07:14:46","slug":"nested-single-and-double-quotes","status":"publish","type":"post","link":"https:\/\/ibex.tech\/javascript\/text\/nested-single-and-double-quotes","title":{"rendered":"Nested single and double quotes"},"content":{"rendered":"\n<p>If you&#8217;re using say onclick() and .innerHTML= as part of some inline javascript you may well run into a nested quotes issue.  For example, maybe within your .innerHTML=&#8217; you want to give some element an ID &#8211; you find you can&#8217;t because you need to surround that ID parameter with quotes and you&#8217;ve used say double quotes for onclick=&#8221; and then single quotes for innerHTML=&#8217;<\/p>\n\n\n\n<p>The solution?<\/p>\n\n\n\n<p>You can&#8217;t escape the new single or double quotes you want to add for your element inside the innerHTML=&#8217;, it doesn&#8217;t work.<\/p>\n\n\n\n<p>You need to change your onclick=&#8221; to call a new function into which you place your innerHTML=&#8217;, freeing you up to then use double quotes within it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re using say onclick() and .innerHTML= as part of some inline javascript you may well run into a nested quotes issue. For example, maybe within your .innerHTML=&#8217; you want to give some element an ID &#8211; you find you can&#8217;t because you need to surround that ID parameter with quotes and you&#8217;ve used say [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62],"tags":[],"class_list":["post-3689","post","type-post","status-publish","format-standard","hentry","category-text"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/3689","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=3689"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/3689\/revisions"}],"predecessor-version":[{"id":3690,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/3689\/revisions\/3690"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/media?parent=3689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/categories?post=3689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/tags?post=3689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}