jquery的事件没有on,js的有。
1、show()
<html lang="en"> <head> <meta charset="UTF-8"> <title>魔降风云变</title> <style> #box{ width: 200px; height: 200px; background-color: red; display: none; } </style> </head> <body> <button id="btn">动画</button> <div id="box"></div> <script type="text/javascript" src="js/jquery.js" charset="utf-8"></script> <script type="text/javascript"> $('#btn').click(function () { $('#box').show() }) </script> </body> </html>
按钮.click事件。默认不显示的内容.show(),显示出来
一开始是没有的:
点击一下就出现了。
show中可以添加毫秒,1000毫秒是一秒。
<html lang="en"> <head> <meta charset="UTF-8"> <title>魔降风云变</title> <style> #box{ width: 200px; height: 200px; background-color: red; display: none; } </style> </head> <body> <button id="btn">动画</button> <div id="box"></div> <script type="text/javascript" src="js/jquery.js" charset="utf-8"></script> <script type="text/javascript"> $('#btn').click(function () { $('#box').show(2000) }) </script> </body> </html>
$('#btn').click(function () { $('#box').show(2000) })