skip to Main Content

I can get selected the html tag with the position of mouse ?

when i move with the mouse i can update for exmpel the border of tag in the position of mose .

2

Answers


  1. You can use mouseover event and get the event.target.

    document.body.addEventListener('mouseover', (event) => console.log(event.target), false);
    
    Login or Signup to reply.
  2. You can use mouseover event on document and then can get tag name as below:

    $(document).mouseover(function(e){
         let tagName = e.target.nodeName;
         //you can also get class in this as below
         let tagClass = e.target.className;    
    });
    

    Then you can add css on class/id or tag.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search