1 工作空间和jsp页面编码改为utf-8
2 jQuery的主函数
3 jqurey对象和Dom对象的转化
只需要用$()括起来
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../js/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(function(){
})
function myclick(){
var div1 = document.getElementById("myinput");
// 把dom转化成jquery对象
var jdiv1 = $(div1);
alert(jdiv1.val());
// jquery对象转为dom对象
// jdiv1[0],jdiv1.get(0)
}
</script>
</head>
<body>
<input id="myinput" type="text">
<input value="点击" type="button" onclick="myclick()">
</body>
</html>
网友评论