Adding a slide toggle on WordPress

WordPress has default jQuery. So, no need to load this file explicitly. JS Code: jQuery(‘#toggle-onoff-network’).on({ ‘click’: function () { var origsrc = jQuery(this).attr(‘src’); var src=””; if (origsrc == “https://wordpress.stackexchange.com/questions/166823/img1_on.png”) src=”img2_on.png”; if (origsrc == ‘img2_on.png’) src=”https://wordpress.stackexchange.com/questions/166823/img1_on.png”; jQuery(this).attr(‘src’, src); } }); // The script jQuery( “#netywork-toggle” ).click(function() { jQuery( “#share-stuff” ).slideToggle( “slow”, function() { // Animation complete. … Read more

Simplest ajax form not working when it should

I have been investing some quality time (and headaches) with WP ajax so I understand where you are coming from. In all honesty, it could be anything from an error in your JS code or something completely bizarre, like: add_action(‘wp_ajax_UpdateMeta’, ‘UpdateMeta’); Should be changed to: add_action(‘wp_ajax_updatemeta’, ‘UpdateMeta’); … to remove the capitals because by some … Read more

jQuery function not working

You need to wrap your jQuery click event in a DOM ready function. (function($) { $(‘.signUp’).click(function() { $(‘.signUpForm’).toggle(); }); })(jQuery);

Prevent other versions of jquery from loading on static front page

Maybe I am on thin ice but lets try. Assuming that you already have the correct jquery version(you want to use) downloaded and copied to a folder. (The same js folder as the jquery.rwdImageMaps.js would be logical imho) Imho you also can delete folowing code part <script type=”text/javascript” src=”https://wordpress.stackexchange.com/questions/195723/<?php echo get_stylesheet_directory_uri(); ?>/js/jquery.rwdImageMaps.js”></script> from that front-page.php … Read more

Referrer URL with jQuery or Javascript – Cache & Referrer URL Issue

I don’t have the answer build on cookie, but I think this isn’t sensitive data, you can try localStorage. jQuery(document).ready(function($){ var initreferrer = document.referrer; if(initreferrer.indexOf(‘yourdomain.com’) === -1 ) { // Check if the referer is your site or not. If not( return -1 ) set the localStorage. localStorage.setItem(“mysite_referrer”, initreferrer); } }); Then you can use … Read more

jQuery script is not working inside ‘head’ tag

If your script depends on jQuery, you have to declare that dependency to make sure WordPress will enqueue it earlier than yours. wp_enqueue_script( ‘my-jquery-script’, get_stylesheet_directory_uri() . ‘/js/my-jquery-script.js’, [ ‘jquery’ ] /* declare the dependency */ );