您的位置:首页 > Web前端 > JQuery

jquery复习笔记1 - ready() show() hide() toggle()

2014-05-21 14:52 656 查看
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs
/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(
function(){
$("#b1").click(
function(){
$("p").hide();
}
);
$("#b2").click(
function(){
$("p").show();
}
);
}
);
</script>
</head>

<body>
This is my JSP page. <br>
<p>我将被隐藏掉</p>
<button id="b1">隐藏</button>
<button id="b2">显示</button>
</body>
</html>


心得:可在$(document).ready();方法中进行方法的绑定,比如给按钮绑定某些事件。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: