首页javascriptvisibilityjQuery Style - 如何显示和隐藏元素

jQuery Style - 如何显示和隐藏元素

我们想知道如何显示和隐藏元素。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<style type='text/css'>
div {
  display: table;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $('div').css('display','none');
    $('button').on('click',function(){
        $('div').toggle();
    });
});
</script>
</head>
<body>
  <button>toggle</button>
  <div>table div</div>
</body>
</html>