Javascript Pass Variable To Style
screen_w = window.innerWidth; screen_h = window.innerHeight; to get the window deminsions and then set it to a variable. Is there a way to take that variable and then use it in my
Solution 1:
You can't pass variables to CSS.
You can, however, use javascript directly to change the image style (including dimensions).
Solution 2:
You can use JS to modify CSS, see this question:
Solution 3:
<script >
window.onload = function() {
$.ajax({url: "api/<route-name>", success: function(result){
console.log(result.data[16]['value']);
document.documentElement.style.setProperty('--my-variable-name', result.data[14]['value']);
}});
}
<style>
.gender_radio .radio-list .is-checked {
background-color: var(--my-variable-name) !important;
}
Post a Comment for "Javascript Pass Variable To Style"