-1
<label>
 <input type="checkbox">
</label>

I have no experience with jQuery or Javascript but I would like to know if it is possible to disable sroll on a whole page when a checkbox is ticked and enable it again when it is unticked, I would love a code example

Jordan
  • 1
  • 1

1 Answers1

1

Yes, you can do this.

$('#test').change(function() {
  if ($('#test').is(":checked")) {
    $('body').css('overflow','hidden');
  } else {
    $('body').css('overflow','auto');
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label>
 <input id="test" type="checkbox">
</label>
Matt
  • 172
  • 2
  • 2
  • 10