Overriding check box in JavaScript with jQuery

前端 未结 3 1988
迷失自我
迷失自我 2020-12-07 04:32

Help with unit testing checkbox behavior. I have this page:




    
    

        
3条回答
  •  星月不相逢
    2020-12-07 05:32

    How about using change instead of click?

    $('#makeHidden').change(function() {
                var isChecked = $(this).is(':checked');
    
                if (isChecked) {
                    $('#displayer').hide();
                }
                else {
                    $('#displayer').show();
                }
                return false;
            });
    

    The return false; won't be in the way since the event is fired as a result of the change having occurred.

提交回复
热议问题