Link href Property - Change style sheet: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Link

Description

Link href Property - Change style sheet:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<link id="myLink" rel="stylesheet" type="text/css" href="http://java2s.com/style/bootstrap.min.css">
</head>/*w w  w.  j av a  2  s. c  o m*/
<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").href = "style2.css";
}
</script>

</body>
</html>

Related Tutorials