{"id":14792,"date":"2019-03-20T07:51:52","date_gmt":"2019-03-20T07:51:52","guid":{"rendered":"http:\/\/rnbtheme.com\/documentation\/?p=14792"},"modified":"2021-12-22T08:40:22","modified_gmt":"2021-12-22T08:40:22","slug":"close-accordion-on-click","status":"publish","type":"post","link":"https:\/\/rnbtheme.com\/documentation\/knowledge-base\/close-accordion-on-click","title":{"rendered":"Close accordion on click"},"content":{"rendered":"<p>By default, there is no option to close the accordion on click but there is a solution.<\/p>\n<p>You can add the following JS code to achieve\u00a0this:<\/p>\n<p>&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\n(function($){<br \/>\n$(&#8220;.<span class=\"il\">vc_tta<\/span>&#8211;<span class=\"il\">accordion<\/span>\u00a0.<span class=\"il\">vc_tta<\/span>&#8211;<span class=\"il\">panel<\/span>&#8220;).on(&#8220;click&#8221;,fun<wbr \/>ction(){<br \/>\nvar self = $(this);<br \/>\nif($(this).hasClass(&#8220;vc_<wbr \/>active&#8221;)){<br \/>\n$(this).find(&#8220;.<span class=\"il\">vc_tta<\/span>&#8211;<span class=\"il\">panel<\/span>&#8211;<wbr \/>body&#8221;).slideUp(400,function(){<br \/>\nself.removeClass(&#8220;vc_active&#8221;);<br \/>\n});<br \/>\nreturn false;<br \/>\n}<br \/>\n});<br \/>\n})(jQuery);<br \/>\n&lt;\/script&gt;<\/p>\n<p>Add the code to <del class=\"support-arrow-right\">Theme options<\/del>\u00a0<del class=\"support-arrow-right\">General options<\/del>\u00a0<del class=\"support-arrow-right\">Custom CSS\/JS<\/del> <del>Custom JS<\/del> field.<\/p>\n<p>Note, in case you have links inside the accordion they will not be clickable, they will close the accordion.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, there is no option to close the accordion on click but there is a solution. You can add the following JS code to achieve\u00a0this: &lt;script type=&#8221;text\/javascript&#8221;&gt; (function($){ $(&#8220;.vc_tta&#8211;accordion\u00a0.vc_tta&#8211;panel&#8220;).on(&#8220;click&#8221;,function(){<\/p>\n","protected":false},"author":30,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[136,216,74,22,33],"_links":{"self":[{"href":"https:\/\/rnbtheme.com\/documentation\/wp-json\/wp\/v2\/posts\/14792"}],"collection":[{"href":"https:\/\/rnbtheme.com\/documentation\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rnbtheme.com\/documentation\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rnbtheme.com\/documentation\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/rnbtheme.com\/documentation\/wp-json\/wp\/v2\/comments?post=14792"}],"version-history":[{"count":15,"href":"https:\/\/rnbtheme.com\/documentation\/wp-json\/wp\/v2\/posts\/14792\/revisions"}],"predecessor-version":[{"id":15520,"href":"https:\/\/rnbtheme.com\/documentation\/wp-json\/wp\/v2\/posts\/14792\/revisions\/15520"}],"wp:attachment":[{"href":"https:\/\/rnbtheme.com\/documentation\/wp-json\/wp\/v2\/media?parent=14792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rnbtheme.com\/documentation\/wp-json\/wp\/v2\/categories?post=14792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rnbtheme.com\/documentation\/wp-json\/wp\/v2\/tags?post=14792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}