首页javascriptanchorjQuery HTML Element - 如何单击后附加到Body...

jQuery HTML Element - 如何单击后附加到Body...

我们想知道如何单击后附加到Body。...

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<style type='text/css'>
a {
  color: blue;
}

a:active, a.active {
  color: red;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $(document).ready(function () {
        $('button').click(function () { $('a').toggleClass('active') }); 
    });
});
</script>
</head>
<body>
  <a href="#">Link</a>
  <button>Activate/Deactivate</button>
</body>
</html>