- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Wrong js in WordPress
Hi.
I have problem with simple jquery function. Everything seems fine to me but it says:
Uncaught SyntaxError: Unexpected identifier on line 8.
Here is my code:
jQuery.noConflict();
/*Change images src on hover*/
jQuery(document).ready(function($) {
$(‘.bnt1Program a’).bind(‘mouseover’, function() {
$(‘img#programHeaderBnt1’).attr(“src”, “logo.png”);
}
$(‘.bnt2Program a’).bind(‘mouseover’, function() {
$(‘img#programHeaderBnt2’).attr(“src”, “logo2.png”);
}
$(‘.bntWProgram a’).bind(‘mouseover’, function() {
$(‘img#programHeaderBntW’).attr(“src”, “logo3.png”);
}
}
And in functions php i used:
function my_load_scripts() {
if (!is_admin()) {
wp_register_script(‘changeHImag’, ‘/wp-content/themes/bnt/js/chHIm.js’);
wp_enqueue_script(‘changeHImag’,’/wp-content/themes/bnt/js/chHIm.js’, array(‘jquery’));
}
}
add_action( ‘wp_enqueue_scripts’, ‘my_load_scripts’ );
What’s wrong ?
Thank you in advance.
Do you really need `jQuery.noConflict();`?
Add closing brackets for your bind functions ( `);` after each `}` )
Thank you.
But now it’s says:
Uncaught SyntaxError: Unexpected end of input .
After each of your binds, you’re only closing it with `}`. It needs to be `});`.
Same thing at the very end of your document ready.
Thank you :)