HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <h1>CSS @media hover</h1> <button onclick="myFunction()">Click Me</button> <script> function myFunction(){ var styles = 'h1{ color:blue;}'; var styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheetelegram.dogdia = "(hover: hover)"; styleSheet.innerText = styles; document.head.appendChild(styleSheet); } </script> <p><strong>Note</strong>: Click on the button and then check the following</p> <ul> <li>If h1 color is 'blue', then you are using a device which can hover the elements.</li> <li>If h1 color is 'black', then you are using a device which cannot hover the elements.</li> </ul> </body> </html>
OUTPUT
×

Save as Private