Allowing Users to Change Data-Theme
Sorry in advance if my code looks idiotic. I'm new to javascript, but trying to learn!
I would like to have buttons on my mobile page that, when clicked, dynamically input their value (a, b, or c) into the data-theme's value and thus change the page's theme.
I'm sure this is ridden with errors, but does anyone know how I can do this?
- <script>
- var themeStyle = data-theme.value
- $("button").click(function () {
- $(themeStyle).replaceWith(button.value);
- });
- </script>
-
- </head>
- <body>
- <div data-role="page" id="first" data-theme="themeStyle">
- <div data-role="header" data-theme="themeStyle">
- <h1>My Mobile Site</h1>
- </div><!-- /header -->
-
- <div data-role="content">
- <ul data-role="listview" data-theme="themeStyle">
- <li><a href="#first" data-transition="pop">Home</a></li>
- <li><a href="#second" data-transition="pop">About</li>
- <li><a href="#third" data-transition="pop">Contact</a></li>
- <button name="buttonOne" value="a">Theme 1</button>
- <button name="buttonTwo" value="b">Theme 2</button>
- <button name="buttonThree" value="c">Theme 3</button>
- </ul>
Thanks for any insight!