Problem loading jQuery script from custom file in WordPress
-
Hello. I have problem to load jquery script from created file (myscriptos.js) to all my pages (to header). First I tried to load my scripts by using wp_enqueue_script to my functions.php file and create new js file (myscriptos.js). Used this lines:
(function wpb_adding_scripts() {wp_register_script(‘mujscript’, get_template_directory_uri() . ‘/myscriptos.js’, array(‘jquery’),’1.0′, false); wp_enqueue_script(‘mujscript’); } add_action( ‘wp_enqueue_scripts’, ‘wpb_adding_scripts’ );
Then when I checked in source code on updated site It has appeared.
Then I have pasted this code to the new js file (myscriptos.js):
$(document).ready(function(){ $(“#button0”).click(function(){ $(“#button1”).fadeToggle(); $(“#button2”).fadeToggle(“slow”); $(“#button3”).fadeToggle(3000); }); });
Then I saved it, and created these buttons on the top of this site, this script supposed to do: When I click on Button0(black one) then Button 1,2 and 3 should fade. But nothing is happening and it does not seem the script is loading Could you please somebody help me? Thank you in advance.
For whole desciptions of problem with picture is this link:
[ redundant link removed ]- This topic was modified 4 years, 10 months ago by .
- This topic was modified 4 years, 10 months ago by .
- This topic was modified 4 years, 10 months ago by . Reason: code fixed
The page I need help with: [log in to see the link]
- The topic ‘Problem loading jQuery script from custom file in WordPress’ is closed to new replies.