{"id":3985,"date":"2023-07-18T20:09:42","date_gmt":"2023-07-18T18:09:42","guid":{"rendered":"https:\/\/www.knowboard.de\/?p=3985"},"modified":"2023-07-23T14:13:08","modified_gmt":"2023-07-23T12:13:08","slug":"add-jquery-toggle-script-to-footer-in-wordpress","status":"publish","type":"post","link":"https:\/\/www.knowboard.de\/add-jquery-toggle-script-to-footer-in-wordpress\/","title":{"rendered":"Add JQuery toggle Script to footer in WordPress"},"content":{"rendered":"\n
Dies ist ein einfaches Beispiel daf\u00fcr, wie man in WordPress ein JQuery Code in den Footer einbringt, um bspw. ein Toggle Skript auszul\u00f6sen. Das kann sinnvoll sein, wenn man bestimmte Bereiche erst einblenden m\u00f6chte, wenn der Besucher es w\u00fcnscht. So kann man das Ganze Layout \u00fcbersichtlicher gestalten und muss es nicht mit zu vielen Informationen zum\u00fcllen.<\/p>\n\n\n\n
add_action( 'wp_footer', function() { ?>\n <script>\n\t \n\t jQuery('#trigger1').click(function() {\n\t\t jQuery(\"#trigger1 figure.down\").toggleClass('hidden');\n\t\t jQuery(\"#trigger1 figure.right\").toggleClass('hidden');\n\t\t jQuery(\"#apply1\").fadeToggle(\"fast\");\n\n\t\t jQuery(\"#trigger2 figure.down\").addClass('hidden');\n\t\t jQuery(\"#trigger2 figure.right\").removeClass('hidden');\n\t\t jQuery(\"#apply2\").fadeOut(\"fast\");\n\t }); \n\n\t jQuery('#trigger2').click(function() {\n\t\t jQuery(\"#trigger2 figure.down\").toggleClass('hidden');\n\t\t jQuery(\"#trigger2 figure.right\").toggleClass('hidden');\n\t\t jQuery(\"#apply2\").fadeToggle(\"fast\");\n\t\t \n\t\t jQuery(\"#trigger1 figure.down\").addClass('hidden');\n\t\t jQuery(\"#trigger1 figure.right\").removeClass('hidden');\n\t\t jQuery(\"#apply1\").fadeOut(\"fast\");\n\t }); \n\t \n\t \/*\n\t jQuery('#trigger2').click(function() {\n\t\t \/\/alert('dfsd');\n\t\t jQuery(\".apply2-img img.wpex-align-middle\").attr(\"src\",\"\/wp-content\/uploads\/2022\/07\/arrow-blue-down.svg\");\n\t });\n\t \n\t \n jQuery(function(){ \/\/on document ready\n jQuery(document).scroll(function (e) { \/\/bind scroll event\n\n var intBottomMargin = 300; \/\/Pixels from bottom when script should trigger\n\n \/\/if less than intBottomMargin px from bottom\n if (jQuery(window).scrollTop() >= jQuery(document).height() - jQuery(window).height() - intBottomMargin) {\n jQuery(\".vcex-loadmore a\").click(); \/\/trigger click\n }\n\n });\n});*\/\n\t \n <\/script>\n<?php }, 99 );\n\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"Dies ist ein einfaches Beispiel daf\u00fcr, wie man in WordPress ein JQuery Code in den Footer einbringt, um bspw. ein Toggle Skript auszul\u00f6sen. Das kann sinnvoll sein, wenn man bestimmte Bereiche erst einblenden m\u00f6chte, wenn der Besucher es w\u00fcnscht. So kann man das Ganze Layout \u00fcbersichtlicher gestalten und muss es nicht mit zu vielen Informationen…<\/p>\n","protected":false},"author":1,"featured_media":3996,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[77,6],"tags":[],"class_list":["post-3985","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery","category-wordpress","entry","has-media"],"_links":{"self":[{"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/posts\/3985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/comments?post=3985"}],"version-history":[{"count":2,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/posts\/3985\/revisions"}],"predecessor-version":[{"id":3995,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/posts\/3985\/revisions\/3995"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/media\/3996"}],"wp:attachment":[{"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/media?parent=3985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/categories?post=3985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/tags?post=3985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}