1、jQuery 是一个轻量级 JavaScript 库
2、在jsp/HTML页面头部<head></head>导入jQuery.jsp
3、案例分析
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){ --防止文档没有完全加载进来是运行jQuery代码
$("button").click(function(){
--按钮点击触发响应的事件
$("p").hide();
--对元素的操作跟CSS选择器一样
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body></html>
$("button").click(function(){
--按钮点击触发响应的事件
$("p").hide();
--对元素的操作跟CSS选择器一样
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body></html>