Javascript examples for CSS Style Property:backgroundColor
Styling parent of active element for background color
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <div> <a href="#" id="x"> content </a> </div> <script type="text/javascript"> document.addEventListener("mousedown",function(e){ e.target.parentElement.style.backgroundColor="red"; });/*ww w .j a v a2 s. c o m*/ document.addEventListener("mouseup",function(e){ e.target.parentElement.style.backgroundColor=""; }); </script> </body> </html>