<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="zzp">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<style type="text/css">
input:focus,textarea:focus{
border:1px solid #f00;
background:#fcc;
}
.focus{
border:1px solid #f00;
background:#fcc;
}
</style>
<script type="text/javascript" src="js/jquery-1.6.4.min.js" ></script>
<script type="text/javascript">
var temp;
$(function(){
$(":input").focus(function(){ //获得焦点
alert(this.id);
alert("获得焦点时的值是:"+$(this).val());
temp=$.trim($(this).val());
alert(temp);
$(this).addClass("focus"); //添加样式
}).blur(function(){ //失去焦点
$(this).removeClass("focus"); //移除样式
alert("失去焦点时的值是:"+$(this).val());
var lastValue = $.trim($(this).val());
if(temp != lastValue && null !=lastValue && "" !=lastValue)
{
alert("值改变了!");
}
else{
alert("值没有变!");
}
/** */
});
});
</script>
</head>
<body>
<form action="#" method="post" id="reFrom">
<fieldset>
<legend>个人信息</legend>
<div>
<label>名称:</label>
<input id="username" type="text" value="admin">
</div>
<div>
<label>密码:</label>
<input id="pass" type="text" value="123456">
</div>
<div>
<label>性别:</label>
<input id="sex" name="sex" type="radio" value="1" checked="checked">男
<input id="sex" name="sex" type="radio" value="2">女
</div>
<div>
<label>详细信息:</label>
<input id="msg" type="text" value="获取值">
</div>
</fieldset>
</form>
</body>
</html>