{"id":2293,"date":"2019-10-30T13:40:04","date_gmt":"2019-10-30T13:40:04","guid":{"rendered":"https:\/\/ibex.tech\/javascript\/?p=2293"},"modified":"2022-02-17T07:14:46","modified_gmt":"2022-02-17T07:14:46","slug":"toggle-options-on-and-off","status":"publish","type":"post","link":"https:\/\/ibex.tech\/javascript\/examples-javascript\/select-examples-javascript\/toggle-options-on-and-off","title":{"rendered":"Toggle Options On and Off"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>  &lt;ul>\n    &lt;li id=\"MyOption1\" class=\"MyClass_NotSelected\" onclick=\"OptionToggle(this);\" >Option 1&lt;\/li>\n    &lt;li id=\"MyOption2\" class=\"MyClass_NotSelected\" onclick=\"OptionToggle(this);\" >Option 2&lt;\/li>\n  &lt;\/ul>\n\n  &lt;script>\n    \/\/----- TOGGLE OPTION -----\n    function OptionToggle (CallingElement) {\n    \n      var CallingElementId = CallingElement.id;\n      \n      if (document.getElementById(CallingElementId).className == \"MyClass_NotSelected\")\n      {\n        document.getElementById(CallingElementId).className = \"MyClass_Selected\";\n      }\n      else\n      {\n        document.getElementById(CallingElementId).className = \"MyClass_NotSelected\";\n      }\n      \n    }\n  &lt;\/script><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[190],"tags":[],"class_list":["post-2293","post","type-post","status-publish","format-standard","hentry","category-select-examples-javascript"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/2293","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=2293"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/2293\/revisions"}],"predecessor-version":[{"id":2294,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/2293\/revisions\/2294"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/media?parent=2293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/categories?post=2293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/tags?post=2293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}