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.

Javascript

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);
    }
</script>

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

HTML

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>

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
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
  Subscribe  
newest oldest most voted
Notify of