Marco Song Marco Song - 1 year ago 105
Javascript Question

JQuery: fadeToggle() works in a wrong way

I have two checkboxes with id

'check1' , 'check2'

two table columns with class

'column1', 'column2'


In js file

$(document).ready(function() {

$('#check1').change(function() {

$('#check2').change(function() {

When check1 is checked column shows, then hides when unchecked.
The problem is when check2 is checked column hides, and show when unchecked.

They are code in the same way but works in different way.
What causes the problem, how to fix it? Thanks.

Answer Source

Try this alternative:

    if($(this).is(':checked')) {

    } else {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download