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>

Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
0 Comment authors
Tickets for Dubai expo 2020,Expo 2020 Dubai tickets price,dubai expo 2020 tickets,dubai world expo 2020,dubai 2020 expo dates, Dubai 2020, Dubai Expo 2020, dubai,dubai expo 2020 tickets price, dubai expo 2020 projects, expo dubai,dubai expo 2020 projects, Recent comment authors
newest oldest most voted
Notify of