How to insert jQuery via HTML

0

My question probably has an obvious answer, but I could not find it on google.

I have a website that uses Wordpress. On the site I use a plugin that stopped working (I do not know the reason). I discovered that the cause was a jQuery that for some reason was "not being used" (I do not know the right word for it).

I realized that this was the problem after I inserted this code into the F12 console and everything worked:

jQuery(function($){
    $(document).ready(function(){
        $("h3.symple-toggle-trigger").click(function(){
            $(this).toggleClass("active").next().slideToggle("fast");
            return false;
        });
    });
});

How to make this code load with the page without having to insert it into the console?

    
asked by anonymous 30.03.2015 / 21:09

1 answer

2

This code is redundant. You have two options:

1. Insert this in the HTML header:

<head>
...
<script>
jQuery(function($){
    $("h3.symple-toggle-trigger").click(function(){
        $(this).toggleClass("active").next().slideToggle("fast");
        return false;
    });
});
</script>
</head>

2. (or) Insert this just before closing the body:

<body>
...
<script>
$("h3.symple-toggle-trigger").click(function(){
    $(this).toggleClass("active").next().slideToggle("fast");
    return false;
});
</script>
</body>
    
30.03.2015 / 21:52