jQuery 是一个 JavaScript 库。jQuery 极大地简化了 JavaScript 编程。
jQuery 是一个“写的更少,但做的更多”的轻量级 JavaScript 库。
<!DOCTYPE html> <html> <head> <script src="../jquery/jquery-1.11.1.min.js"></script> <script> $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); </script> </head> <body> <p>如果您点击我,我会消失。</p> <p>点击我,我会消失。</p> <p>也要点击我哦。</p> </body> </html>
<head> <script type="text/javascript" src="jquery.js"></script> </head>提示:请注意,<script> 标签应该位于页面的 <head> 部分。
<html> <head> <script type="text/javascript" src="../jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button type="button">Click me</button> </body> </html>注释:演示了 jQuery 的 hide() 函数,隐藏了 HTML 文档中所有的 <p> 元素。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script> <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js"></script>
评论