Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to use jQuery to scroll the div content vertically.

I have used the following line of code in function.php

add_action( 'wp_enquque_scripts', 'my_script_enqueue' );

function my_script_enqueue() {
    wp_enqueue_script( 'my-jquery', '/wordpress/wp-content/themes/MyTheme/js/jquery-1.9.0.js', array( 'jquery' ) );
}

then i have included a JS file in my PHP file as follows:

<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/dw_scroll_c.js"></script>

In that JS file I am just displaying as alert as follows:

jQuery( document ).ready( function( $ ) {
    alert('hi');
});

But it's not working.

share|improve this question
    
Please read wordpress.stackexchange.com/questions/45437/… –  toscho Jul 25 '13 at 10:24
add comment

2 Answers 2

wp_enqueue_script( 'my-jquery', get_stylesheet_directory_uri() .'/js/jquery-1.9.0.js', array( 'jquery' ) );

check for jquery error also check with source code if file is being loaded or not. you must have included jquery library before including your js file.

share|improve this answer
add comment

Do not include js file in your php files, instead use the hook. below code will work for you. See the dependency parameter for wp_enqueue_script function. Your dw sroll file is dependent on jQuery.

add_action( 'wp_enquque_scripts', 'my_script_enqueue' );

function my_script_enqueue(){
wp_enqueue_script('dw_scroll_c','/js/dw_scroll_c.js',array( 'jquery' ));
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.