Issues trying to use/apply event handler on specific html element

Viewed 2

I would like some advice on how to specify the element for certain event handler. I'm trying to change the color on a paragraph when I click on it but it change the color regardless of where I click on the browser.

   function onmouseA(){
       
        
       document.getElementById("test").style.color = "#C5D9FF";
   }
   document.onmousedown = onmouseA;
  

I actually did specify the

with the id="test", but it doesn't work properly, need some advice, thanks.

0 Answers
Related