联系我们
简单又实用的WordPress网站制作教学
当前位置:网站首页 > 网页前端技术 > 正文

Jquery焦点与失去焦点示例应用 - Web前端

作者:98wpeu发布时间:2026-07-01分类:网页前端技术浏览:2


导读:复制代码代码如下:$(function(){$("#input").focus(function(){//#input换成你的input的ID//这里写获得焦点之后运行的代码...
复制代码 代码如下:
$(function(){
$("#input").focus(function(){//#input换成你的input的ID
//这里写获得焦点之后运行的代码。
}).blur(function(){
//$(".scroll-question").CSS("display","none");
});
})

})

live要1.4才支持,以下ie,firefox都没问题
复制代码 代码如下:
<!DOCtypehtml PUBLIC "-//W3C//DTD xhtml 1.0 Transitional//EN" "http://www.w3.org/TR/xHTML1/DTD/xhtml1-transitional.dtd">
<html xmlns="HTTP://www.w3.org/1999/xhtml">
<head>
<meta http-eqUIv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="/JS/JQuery-1.4.4.js"></script>
<script>
$(document).ready(function()
{
$("#nameBefore").dblclick(function()
{
$("#nameBefore").ReplaceWith("<div id='nameIn'><input type='text' name='nameInVal' id='nameInVal' value='In' /></div>");
}
);
//失去焦点以后
$("#nameInVal").live("blur",function()
{
alert('nameInVal已失去焦点');
}
);
}
);
</script>
</head>
<body>
<FORM name="testfm" method="post" action="save.PHP">
<table>
<tr><td>1</td><td><div id='nameBefore'>Before</div></td></tr>
</table>
</form>
</body>
</html>

标签:焦点示例WebJquery


网页前端技术排行
最近发表
网站分类
标签列表