<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Title</title>
    <style >
        .hide{
            display:none
        }
    </style>

</head>
<body>
<input id=22 type="button" value="开关"/>
<div class="a hide">fffff</div>
<script src="jquery-1.12.4.js"></script>
<script>
//  点击按钮如果有hide 就移除,如果没有就加上hide
//    $('#22').click(function () {
//        if ($('.a').hasClass('hide')){
//             $('.a').removeClass('hide')
//        }else
//        $('.a').addClass('hide')
//    })

$("#22").click(function () {
     $('.a').toggleClass('hide')
})
//toggleClass有的话我你去的,没有的加上
</script>
</body>
</html>
开关

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-11-01
  • 2021-12-04
  • 2021-11-22
猜你喜欢
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-10-10
相关资源
相似解决方案