• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

132
Views
After "go to previous page" checkbox remains checked, but won't be detected by jquery

I have an array of checkboxes which can be used in a sort of calendar app. Whenever the checkbox gets checked, a label should become visible. My HTML looks something like this:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    CheckVisibility();
})

function CheckVisibility(){
  if($('#cb').is(':checked')){
    $('#label').show()
  }
  else{
    $('#label').hide()
  }
}
</script>
<table>
    <tr>
        <td><input type=checkbox id="cb" onchange="CheckVisibility()"/></td>
        <td><label id="label" style="display : none">Monday</label></td>
    <tr>
</table>

And it works fine on first load. However, when I return to the previous page, the checkbox is still checked. This is the behaviour I want, but it won't get registered as "checked" when passing $(document).ready fires of CheckVisibility(). Any idea's?

almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error