Javascript not working on index.php but it is working on single post’s page

The proper way to enqueue a script is as follows: function mathJax_scripts() { wp_enqueue_script( ‘mathjax-js’, http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML’, array(), ‘2.7.1’, false ); } add_action( ‘wp_enqueue_scripts’, ‘mathJax_scripts’ ); I added the version number (2.7.1) and I flipped the final parameter to ‘false’ – that last parameter asks ‘add script to footer?’, true means yes, false means no. Then … Read more

Javascript button to call custom fields data

Is this something you wish to achieve? <!DOCTYPE html> <html> <body> <h1>My First JavaScript</h1> <button type=”button” onclick=”var the_id=document.getElementById(‘my_field’).value; document.getElementById(‘demo’).innerHTML= document.getElementById(the_id).innerHTML;”> Click me to display some other string.</button> <p id=”demo”></p> <input id=”my_field” type=”text”></a> <div id=”someother”>Hi there!</div> </body> </html>

Add Javascript/Html into a WordPress

This plugin allows custom JS and custom CSS on a per post/page basis. https://wordpress.org/plugins/art-direction/ If you find that it is not compatible with your WP install, look for other plugins that allow custom JS and CSS. If you’re looking for a more robust solution, you can do something like the following: /* overlay-contact-form.css */ #overlayContactForm … Read more

Live Time on WP showing weirdly [closed]

Here’s an updated version of the code which fixes the extra zero caused by the redundant time checks in startTime(): JavaScript function startTime() { var d=new Date(); var h=d.getHours(); var m=d.getMinutes(); var s=d.getSeconds(); h = h % 12; h = h ? h : 12; // the hour ‘0’ should be ’12’ var ampm = … Read more

Why the images on mi javascript are not found?

You are missing /wp-content/themes/YOUR_theme_NAME_FOLDER like this: function sliderimgchange(){ if ($(window).width() <= 600) { var sliderOne = $(‘.slideuno’).attr(‘src’, ‘/wp-content/themes/YOUR_theme_NAME_FOLDER/images/sliderone-mobile.jpg’), sliderTwo = $(‘.slidedos’).attr(‘src’, ‘/wp-content/themes/YOUR_theme_NAME_FOLDER/images/slidertwo-mobile.jpg’), sliderThree = $(‘.slidetres’).attr(‘src’, ‘/wp-content/themes/YOUR_theme_NAME_FOLDER/images/sliderthree-mobile.jpg’); } else if ($(window).width() > 600) { var sliderOne = $(‘.slideuno’).attr(‘src’, ‘/wp-content/themes/YOUR_theme_NAME_FOLDER/images/sliderone.jpg’), sliderTwo = $(‘.slidedos’).attr(‘src’, ‘/wp-content/themes/YOUR_theme_NAME_FOLDER/images/slidertwo.jpg’), sliderThree = $(‘.slidetres’).attr(‘src’, ‘/wp-content/themes/YOUR_theme_NAME_FOLDER/images/sliderthree.jpg’); } }

Making the HTML list to a checkbox tree with the plugin jstree [closed]

This worked for me. Basically jquery was missing through <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js”> </script> and the wrong PHP tags. Thanks for that. You can find the full code below. <title> Hi all</title> <link rel=”stylesheet” href=”https://wordpress.stackexchange.com/questions/295053/<?php echo get_stylesheet_directory_uri().”/js/jstree/dist/themes/default/style.min.css’;?>” /> <div id=”data”> <ul> <li>One</li> <li>Two</li> <li>Three <ul> <li>Bike</li> <li>Ride</li> </ul> </li> <li>JOKE</li> </ul> </div> <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js”> </script> <script src=”<?php … Read more