javascript - jQuery Accordion stopped working -
after mess ftp client, wordpress' header.php got deleted, need re-code , former working jquery script stopped working, can't find problem.
it accordion script can have multiple sections open @ same time:
<script type="text/javascript"> $(document).ready(function() { $(".post-list").addclass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset") .find("h3.entry-title") .addclass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom") .hover(function() { $(this).toggleclass("ui-state-hover"); }) .click(function() { $(this) .toggleclass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom") .next().toggleclass("ui-accordion-content-active").slidetoggle(); return false; }) .next() .addclass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom") .hide(); var d= 0; $('.post').each(function() { $(this).delay(d).fadein(300); d += 100; }); }); </script>
it's supposed find h3's, add classes , hide following div's. put in head-area of header.php, necessary libraries loaded, somehow script doesn't seem work @ all.
can find mistake or suggest might wrong script's implementation?
note: tried exact same script on local dummy website , works.
thanks!
if you're getting "can't find variable: $" error on console, means jquery not loaded or conflicts other libraries.
first check whether window.$
or window.jquery
exist on console.
and try use jquery
instead $
<script type="text/javascript"> $.noconflict(); jquery(document).ready(function() { jquery(".post-list").addclass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset") .find("h3.entry-title") .addclass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom") .hover(function() { jquery(this).toggleclass("ui-state-hover"); }) .click(function() { jquery(this) .toggleclass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom") .next().toggleclass("ui-accordion-content-active").slidetoggle(); return false; }) .next() .addclass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom") .hide(); var d= 0; jquery('.post').each(function() { jquery(this).delay(d).fadein(300); d += 100; }); });
Comments
Post a Comment