首页javascripttriggerjQuery Method - 如何使用toggleClass()单击时转换类属性...

jQuery Method - 如何使用toggleClass()单击时转换类属性...

我们想知道如何使用toggleClass()单击时转换类属性。...

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    $(document).ready(function () {
        $('.botton3').click(doSomething);
        $('.botton2').click(doTrigger);
    });
    function doTrigger() {
        $('.botton3').trigger('click');
    }
    function doSomething() {
        console.log('boo!');
    }
});
</script>
</head>
<body>
  <div class="botton1">
    <h2>button1</h2>
  </div>
  <div class="botton2">
    <h2>button2</h2>
  </div>
  <div class="botton3">
    <h2>button3</h2>
  </div>
</body>
</html>