jquery/javascript modification to header.php
-
I have created a child theme.
I want to add some javascript/jquery to the header.I created a js file and put that in my child js folder.
$(document).ready(function(){
var speed = 3;
var items, scroller = $(‘#scroller’);
var width = 0;
scroller.children().each(function(){
width += $(this).outerWidth(true);
});
scroller.css(‘width’, width);
scroll();
function scroll(){
items = scroller.children();
var scrollWidth = items.eq(0).outerWidth();
scroller.animate({‘left’ : 0 – scrollWidth}, scrollWidth * 100 / speed, ‘linear’, changeFirst);
}
function changeFirst(){
scroller.append(items.eq(0).remove()).css(‘left’, 0);
scroll();
}
});I included the following lines in the header ( from reading various post on how to do that)
<script type=”text/javascript” src=”https://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js”></script>
<script type=”text/javascript” src=”<?get_stylesheet_directory_uri() . ‘/js/cr_ticker.js’;?></script>
<?php wp_enqueue_script( ‘cr_ticker’ );?>However the code is not working. It does if I include it in the header.php
Can anyone help?
- The topic ‘jquery/javascript modification to header.php’ is closed to new replies.