How to call javascript function (jquery) in a shortcode?

Use wp_enqueue_script() with $in_footer parameter set to true, when loading scripts with your shortcode. To pass data from the PHP part of your code to the JS part use wp_localize_script(). wp_enqueue_script( ‘script_name’, ‘/script-location/script.js’, array(), ‘1.0.0’, true ); $data_array = array( ‘key_1’ => ‘val_1’, ‘key_2’ => ‘val_2’ ); wp_localize_script( ‘script_name’, ‘data_object_name’, $data_array ); You now can …

Read more

Jquery being loaded wrong

since it runs on old jquery ,try adding the old jquery on your footer of your theme, add the jquery manually and add script noconflict. You can get jquery library list from google cdn View Sample

How to get this jQuary script working?

Oh okay.. I think I solved it. I put the script in the header.php (I think “into the loop” as they say?) just behind the opening <header>-tag: <body> <header> <script type=”text/javascript”> (function($) { $(document).ready(function(){ $(window).scroll(function(){ if ($(this).scrollTop() > 200) { $(‘#menu’).fadeIn(500); } else { $(‘#menu’).fadeOut(500); } }); }); })(jQuery); </script>

Custom Javascript not working? [closed]

There are a few problems but the main one is when sidebarEffects.js is loaded the HTML it’s looking for doesn’t exist yet. So… var container = document.getElementById( ‘st-container’ ) // and buttons = document.querySelectorAll( ‘#st-trigger-effects > button’ ) ) are both empty when the script is run. Easiest way to fix it is to …

Read more

JQuery Login Dropdown not functioning in theme

its working now:- jQuery(function() { var $button = jQuery(‘#loginButton’); var $box = jQuery(‘#site-crhead’); var $form = jQuery(‘#loginForm’); $‘click’,function(login) { console.log($box); $box.toggle(); $button.toggleClass(‘active’); }); $‘click’,function() { return false; }); jQuery(this).live(‘click’,function(login) { if(!(jQuery(‘#loginButton’).length > 0)) { $button.removeClass(‘active’); $box.hide(); } }); }); Just update your code according to you, even your mouseup function was not working, according to …

Read more