Hello there,
I'm currently experimenting with CSS3 variables to adjust elements and various other things dynamically, but I've run into an issue where JQuery's css method seems to ignore any attempt to set a CSS variable. Here is what I've tried:
$(document).ready(function() {
$('#testdiv').css('--bgc','rgb(0,0,255)');
});
div {
--bgc: rgb(255, 0, 0);
background-color: var(--bgc);
width: 50px;
height: 50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div id="testdiv"></div>
According to the setup, the div should initially display as a 50px by 50px red box, and once the page has finished loading, it should change to a blue box. However, the --bgc variable on the DIV remains unchanged. Is there a way to achieve this using JQuery?