当前位置: 首页 > 工具软件 > J-Focus > 使用案例 >

jquery focus的用法

靳祺然
2023-12-01
<%@ 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 'test.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 src="jquery/jquery-1.11/jquery.min.js"></script>
<style>
.focused {    background: #abcdef;}
</style>
<script>
	var test;
	$(function() {
		/* $("#content").delegate("*", "focus blur", function(event) { */
		$("#content").delegate("input", "focus blur", function(event) {
			var elem = $(this);
			setTimeout(function() {
				elem.toggleClass("focused", elem.is(":focus"));
			}, 0);
		});
	});
</script>
</head>
<body>
	<div id="content">
		<input type="text"> 
		<input type="text">
		<select>
			<option>select menu1</option>
			<option>select menu2</option>
			<option>select menu3</option>
		</select>
		<div>div</div>
	</div>
</body>
</html>


 类似资料: