vendredi 9 mars 2018

Change style-sheet CSS using Jquery or Js

I am writing a web-app for mobile device, what I am doing is to change dynamically the css style-sheet and store that option for he user, I have been all night long googling method and way to achieve my object but nothing worked for me.

This is the type of button that I am using, and here comes up another problem, because I wasn't able to Check and Uncheck the checkbox.

HTML

<input id="#checkbox" type="checkbox" checked onclick="swapStyleSheet()">

The only thing that worked fine for me is this:

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

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

and in the body

<input id="#checkbox" type="checkbox" checked onclick="swapStyleSheet(Second.css)">

But this is not dynamically, because one the user tap the button is not able to go back and I am not sure that works for a mobile device

Any suggestion how to proceed?




Aucun commentaire:

Enregistrer un commentaire