Change Style Sheet Using javascript

change website css using javascript

Hello friends in these days in every website clients required different-different color scheme and themes so in this article i am going to tell you , how to change website theme.


By using this javascript you can change CSS files on button click.

<script type="text/javascript">
    function swapStyleSheet(sheet) {
        document.getElementById('pagestyle').setAttribute('href', sheet);

<link id="pagestyle" rel="stylesheet" type="text/css" href="css/style.css">


Here are the html button code from here you can Add css files.

<button onclick="swapStyleSheet('css/style.css')">Default</button>
<button onclick="swapStyleSheet('css/blue.css')">Blue</button>
<button onclick="swapStyleSheet('css/pink.css')">Pink</button>