Hi guys, does anyone know how to have a div that auto scrolls to the bottom every 1 second or so, BUT only when a checkbox is checked? Lets say i have a div named. text and a checkbox named scrollcheck. I would like the text div to auto scroll to the bottom only when scrollcheck is checked? Any thoughts or ideas? ( My JS is rubbish btw ) Thanks
You can use following codes: <div><input id="check" type="checkbox" onclick="update()">Auto-scroll</div> <div id="text" style="width: 200px; height: 100px; border: solid 1px grey; overflow: scroll;"> German Chancellor Angela Merkel said Friday that it is Berlin's duty to support the euro currency as she praised the new eurozone agreement on a second bailout for Greece. Merkel said the deal reached Thursday in Brussels to help Greece was a "significant" step that would help Europe and the currency used by the 17-nation eurozone. </div> <script> function update() { var box = document.getElementById('check'); if (!box.checked) return; var tag = document.getElementById('text'); tag.scrollTop = tag.scrollHeight; setTimeout('update()', 1000); } update(); </script> Code (markup):