JavaScript is not Running On my Website

If I use the script tag or link the file the js does not Run if it is a problem with the js here is my code.

$("img").on("contextmenu", function (e) {
    return false;

$("img").mousedown(function (e) {

const toggle = document.querySelector(".toggle");
const menu = document.querySelector(".menu");

/* Toggle mobile menu */
function toggleMenu() {
    if (menu.classList.contains("active")) {
        toggle.querySelector("a").innerHTML = "<i class='fas fa-bars'></i>";
    } else {
        toggle.querySelector("a").innerHTML = "<i class='fas fa-times'></i>";

/* Event Listeners */
toggle.addEventListener("click", toggleMenu, false);
for (let item of items) {
    if (item.querySelector(".submenu")) {
        item.addEventListener("click", toggleItem, false);
    item.addEventListener("keypress", toggleItem, false);
document.addEventListener("click", closeSubmenu, false);

Are you saying that it’s not producing the result you expect or it’s not running? They are very different things.

IT is not making the result

What’s the HTML look like?

Also, what’s closeSubmenu do?

(Clicking on any element on the page will also trigger an eventListener bound to document, unless you prevent bubbling up)

it closes the submenu rom the mobile nav menu and I already got the answer form a faster answer responding place stack overflow. I Had to Load the Jquery

<script src="" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>

If you had posted the html here also as you did at SO then you would have got your answer at the same time.


Did you mean that to sound as passive/aggressive as it does?


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.