Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01733c7

Browse files
committed
JS to updated the CSS Variables
1 parent 608c929 commit 01733c7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

03 - CSS Variables/app.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const inputs = document.querySelectorAll('.controls input');
2+
3+
function handleUpdate() {
4+
const suffix = this.dataset.sizing || '';
5+
6+
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
7+
}
8+
9+
inputs.forEach(input => input.addEventListener('change', handleUpdate));
10+
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));

0 commit comments

Comments
 (0)