jquery - Fixing a JavaScript conflict in Wordpress, help using wp_enqueue_script -


i think (not 100% sure) suffering javascript conflict. using pluggin generate countdown clock on wordpress page, , using simple custom made javascript jquery make div appear , dissapear on page @ points of scrolling.

to make appearing / dissapearing div work correctly added 2 javascript calls header:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/test1.js"></script>  

the first being jquery library , second being custom script. after adding these lines of code header, countdown clock stopped working on website. through little debugging have realized google hosted script causing clock not work.

when have code google hosted jquery library in header receive following error: error = object [object object] has no method 'jcountdown'

i believe solution using wp_enqueue_script , wp_register_script in functions.php file add 2 .js files need, , removing code header. however, un familiar how these bits of code work , can not seem figure out. below code believe needs used in functions.php file, have been unsuccessful in making work.

function notsurewhatgoeshere() {         wp_register_script(notsurewhatgoeshere);         wp_enqueue_script(notsurewhatgoeshere);         }          add_action(notsurewhatgoeshere); 

and here link test webpage: http://jltest.biz/test-1

thank , time.

you have error = object [object object] has no method 'jcountdown'

maybe plugin hasn't loaded properly...

remove jquery added jquery.1.10.2 not supprised doesn't work..

plus - wordpress has added version of jquery.1.8.3

now, in test file have this

var starty = 840; var stopy = 1900;  $(window).scroll(function(){     checky(); });  function checky() {     console.log($(window).scrolltop());      if($(window).scrolltop() > starty && $(window).scrolltop() <= stopy)     {         console.log("show");           $('.fixeddiv').fadein("slow");      }     else     {         console.log("hide");          $('.fixeddiv').fadeout();     } }  checky(); 

wordpress uses jquery.noconflict(); default need make sure wrap code in following

(function( $ ) {      // code here....  }( jquery )); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -