根据复选框checkbox的选中状态来打开或关闭隐藏层

HTML: 

<input type="checkbox" id="check-expert">

<div id="expert" style="display:none">隐藏层</div>

JS:

$(function () {

  if ($("#check-expert").attr("checked") == "checked") {

    $("#expert").css('display', 'block');
  }

  $("#check-expert").on('click', function () {

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

      $("#expert").css('display', 'block');

    } else {

      $("#expert").css('display', 'none');
    }
  })
});

posted @ 2016-05-06 18:10  SKILL·NULL  阅读(761)  评论(0编辑  收藏  举报