Link media Property - Change the media type: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Link

Description

Link media Property - Change the media type:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<link id="myLink" rel="stylesheet" type="text/css" media="screen" href="styles.css">
</head>//from www  .  j a  v a 2  s.c  om
<body>

<h1>I am formatted with a linked style sheet</h1>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myLink").media = "all";
    document.getElementById("demo").innerHTML = "The media type was changed from 'screen' to 'all'.";
}
</script>

</body>
</html>

Related Tutorials