JimmyJames
84
Q:

css on click

<!DOCTYPE html>
<html>
<head>
  <style>
    /* On click: */
    a:active {
      background-color: yellow;
    }
    button:focus {
      background-color: yellow;
    }
    /* On hover: */
    h1:hover {
      background-color: red;
    }
    p:hover {
      background-color: red;
    }
  </style>
</head>
<body>
  <a href="#">Click Me</a>
  <button>Click me</button>
  
  <h1>Hover over me</h1>
  <p>Hover over me</p>
</body>
</html>
2
CSS clicked event
:active {
  css declarations;
}
5
.x-btn:focus, .button:focus, [type="submit"]:focus {
   outline: none;
}
0

:active {
  css declarations;
}
3
a:active  {     background-color: yellow;  }
3
something:active {}
1
P Example
Click on a <p> element to change its text color to red:

 <p id="demo" onclick="myFunction()">Click me to change my text color.</p>

 
<script>
function myFunction() {
    document.getElementById("demo").style.color = "red";
}
</script>
 
1

New to Communities?

Join the community