Created
May 27, 2019 09:05
-
-
Save parsibox/a0ee2cc5411b246fc882953c51543680 to your computer and use it in GitHub Desktop.
change css variables with jquery!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
body { | |
--color: blue; | |
background-color: var(--color); | |
} | |
</style> | |
</head> | |
<body> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
click me! | |
<script type="text/javascript"> | |
$("html").on('click', function() { | |
$("body").get(0).style.setProperty("--color", "hotpink"); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment