I know what you mean about the tutorials. Here's how I do it:
First you need to write your script. In your theme folder create a folder called something like 'js'. Create a file in that folder for your javascript. E.g. your-script.js. Add your jQuery script to that file (you don't need tags in a .js file).<script>
Here is an example of how your jQuery script (in wp-content/themes/your-theme/js/your-scrript.js) might look:
jQuery(document).ready(function($) {
$('#nav a').last().addClass('last');
})
Notice that I use jQuery and not $ at the start of the function.
Ok, now open your theme's functions.php file. You'll want to use the function so that you can add your script whilst also telling WordPress that it relies on jQuery. Here's how to do that:wp_enqueue_script()
add_action( 'wp_enqueue_scripts', 'add_my_script' );
function add_my_script() {
wp_enqueue_script(
'your-script', // name your script so that you can attach other scripts and de-register, etc.
get_template_directory_uri() . '/js/your-script.js', // this is the location of your script file
array('jquery') // this array lists the scripts upon which your script depends
);
}
Assuming that your theme has wp_head and wp_footer in the right places, this should work. Let me know if you need any more help.
WordPress questions can be asked over at WordPress Answers.
JQuery is already enqueue in Wordpress. You do not need to include <script src=''...jquery'/>
You can use HTML block from Elementor and add your HTML code. Javascript Code needs to be enclosed in script tag.
<script>
jQuery(function($) {
$("#image1").click(function() {
$(this).attr("src", "https://lowlifeclothing.co/wp-content/uploads/2020/11/Loop12D.gif");
var url = $(this).attr("data-click-href");
setTimeout(function() {
window.location.href = url;
}, 1000);
});
});
</script>
<img src="https://lowlifeclothing.co/wp-content/uploads/2020/11/Loop12.gif" data-click-href="https://lowlifeclothing.co/shop/" id="image1">
Now when you click on the image, the deer will play dead!
Look at this image for reference code sample -
https://askteammate.com/wp-content/uploads/2020/11/StackOverFlow-Question-64960881.png