Adding JS to one page

Create a new dir and file dedicated to your javascript. /js/scripts.js. Wrap your entire javascript like this: ( function( $ ) { var allStates = $(“svg.us > *”); allStates.on(“click”, function() { allStates.removeClass(“on”); $(this).addClass(“on”); }); } )( jQuery ); Then in your theme’s functions file, put this code. It loads your new js file. function your_scripts() … Read more

Trouble adding inline style after jQuery in the footer!

You are trying to load your inline js script after jQuery just by calling add_action( ‘wp_footer’, ‘myscript’ ); after wp_enqueue_script( ‘jquery’ ); But this will not load your myscript after jQuery. It is not how wp_footer and wp_enqueue_script works. wp_footer has a third argument named “priority”. add_action( ‘wp_footer’, ‘your_function’, 100 ); //100 is priority here. … Read more

Firebug says jQuery is loaded but $() and jQuery() are not defined

jQuery needs to be outside the wrapper like so: <script type=”text/javascript”> (function($) { $(document).ready(function() { alert(‘hello?’); }); })(jQuery); </script> Edit: A better way would be: jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function }); Also make sure any inline script tags are AFTER your call to wp_head(); And … Read more

Enque Javascript in Footer?

The fifth parameter is $in_footer. You have left that out. Add that parameter, set it to true. wp_register_script( ‘jquery’, “http” . ($_SERVER[‘SERVER_PORT’] == 443 ? “s” : “”) . “://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”, false, null, true ); But I echo the concern expressed by @Andrew in a comment. You can cause yourself trouble by deregistering/replacing the core libraries. … Read more

Call a javascript function from another file

The issue you have is that Slider is not accessible outside of its scope as that’s defined by the .ready() though you’ve used shorthand for that. The function needs to be available in the global scope: file1.js function Slider() { this.nb_ele = 10; } jQuery(function($) { // … }); file2.js jQuery(function($) { var slider = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)