javascript - change some css property in a wordpress theme using jquery -
i want create one(or two) button(s) switch theme dark bright, didn't know jquery read in w3schools , other references wrote jquery function change properties in css file:
<script> $(document).ready(function(){ $("button").click(function(){ $("p").css({ "color": "white", }); $("div").css({ "background-color" : "black",}); }); }); </script> i put script in bottom of header tag in header.php file, , add button footer of site
<button class="bright">طرح روشن</button> but when click on button nothings happen, when try code on w3shcools editor works button in my wordpress site nothing. here code in w3shcools editor:
<!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").css({ "color": "white", "background-color": "#98bf21", "font-family": "arial", "font-size": "20px", "padding": "5px" }); }); }); </script> </head> <body> <button>set multiple css properties p elements</button> <p>this paragraph.</p> <p>this paragraph.</p> </body> </html> and if there way call function "href" grateful me how can call it.
you have syntax error, try this,
<script> $(document).ready(function(){ $("button").click(function(){ $("p").css({ "color": "white" }); $("div").css({ "background-color" : "black"}); }); }); </script> you had , after "background-color" : "black" , "color": "white"
and yeah, add jquery library, if haven't this,
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
Comments
Post a Comment