diegomassaro Posted January 22, 2021 Share Posted January 22, 2021 Hello, I attached the code that I used for the slider. I'm using p5.js. It doesn't work if I insert separately the JS code in the sketch.js page. HTML: <input type="range" min="1" max="100" value="50" class="slider" id="myRange"> <p id="demo">Value: </p> Javascript: var slider = document.getElementById("myRange"); var output = document.getElementById("demo"); slider.oninput = function() { output.style.fontSize = slider.value + "px"; } Thank you all! Link to comment Share on other sites More sharing options...
Ingolme Posted January 23, 2021 Share Posted January 23, 2021 If the <script> tag is before the elements in your document then it won't have access to the elements because they haven't been parsed by the browser yet. I recommend putting <script> tags at the bottom of the page, right before the closing </body> tag. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now