javascriptcsscursordocument-body

Cursor hand on hovered links don't disappear with "cursor: none;"


I am trying to use my own cursor only for hovering on links. This is why I don't set cursor: none on the whole body. I am trying to get rid of the hand via JS. in the inspector the body cursor says its cursor: none, but the hand still shows over my cursor

link.addEventListener("mouseover", () => {
    mouseCursor.classList.add("cursorHov");
    document.body.style.cursor = 'none';
});

Solution

  • Actually, you don't even need JavaScript for this. You can just do it in CSS. Like this:

    .link:hover {
        cursor: none;
    }
    

    For HTML:

    <a href="whateverhref.com" class="link">Try hovering over this!</a>
    

    Now, you just need to create links, and if you want them to have no cursor, then give it a class of link. Of course, you could change the class name. Also, just note that whateverhref.com isn't where you would really want to go, it's just a placeholder.