Uncheck a checked box when the browser's Go Back button used

Discussion in 'JavaScript' started by qwikad.com, Feb 15, 2016.

  1. #1
    I know how to do this in jquery. There are two ways:
    
    $(document).ready(function(){
    $('input:checkbox').prop('checked',false);});
    
    Code (markup):
    or
    
    $(document).ready(function(){
    $('#yourcheckbox').prop('checked',false);});
    
    Code (markup):
    What would be an equivalent to this in pure javascript?
     
    qwikad.com, Feb 15, 2016 IP
  2. hdewantara

    hdewantara Well-Known Member

    Messages:
    538
    Likes Received:
    47
    Best Answers:
    25
    Trophy Points:
    155
    #2
    Hi Qwikad.
    I'd probably use
    
    
    document.querySelector('input[type="checkbox"]').checked = false
    Code (JavaScript):
    for the 1st part. Is wrapping it inside $(document).ready() necessary?
     
    hdewantara, Feb 15, 2016 IP