Jquery焦點(diǎn)與失去焦點(diǎn)示例應(yīng)用
更新時(shí)間:2014年06月10日 15:59:27 作者:
這篇文章主要介紹了Jquery焦點(diǎn)與失去焦點(diǎn)示例應(yīng)用,需要的朋友可以參考下
復(fù)制代碼 代碼如下:
$(function(){
$("#input").focus(function(){//#input換成你的input的ID
//這里寫(xiě)獲得焦點(diǎn)之后運(yùn)行的代碼。
}).blur(function(){
//$(".scroll-question").css("display","none");
});
})
})
live要1.4才支持,以下ie,firefox都沒(méi)問(wèn)題
復(fù)制代碼 代碼如下:
<!DOCTYPE html 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>無(wú)標(biāo)題文檔</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>");
}
);
//失去焦點(diǎn)以后
$("#nameInVal").live("blur",function()
{
alert('nameInVal已失去焦點(diǎn)');
}
);
}
);
</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>
您可能感興趣的文章:
- 在js(jquery)中獲得文本框焦點(diǎn)和失去焦點(diǎn)的方法
- jquery中focus()函數(shù)實(shí)現(xiàn)當(dāng)對(duì)象獲得焦點(diǎn)后自動(dòng)把光標(biāo)移到內(nèi)容最后
- input 輸入框獲得/失去焦點(diǎn)時(shí)隱藏/顯示文字(jquery版)
- jQuery 文本框得失焦點(diǎn)的簡(jiǎn)單實(shí)例
- JQuery設(shè)置文本框和密碼框得到焦點(diǎn)時(shí)的樣式
- jQuery表單獲取和失去焦點(diǎn)輸入框提示效果的實(shí)例代碼
- JQuery中使文本框獲得焦點(diǎn)的方法實(shí)例分析
相關(guān)文章
jquery與google map api結(jié)合使用 控件,監(jiān)聽(tīng)器
關(guān)于jquery的獲取不再此處累贅,網(wǎng)上有許多關(guān)于jquery的介紹。2010-03-03jqGrid 學(xué)習(xí)筆記整理——進(jìn)階篇(一 )
這篇文章主要介紹了jqGrid 學(xué)習(xí)筆記整理——進(jìn)階篇(一 )的相關(guān)資料,需要的朋友可以參考下2016-04-04jQuery動(dòng)態(tài)設(shè)置form表單的enctype值(實(shí)現(xiàn)代碼)
本篇文章是對(duì)在jQuery中動(dòng)態(tài)設(shè)置form表單的enctype值的實(shí)現(xiàn)代碼進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-07-07全面解析jQuery中的$(window)與$(document)的用法區(qū)別
這篇文章主要介紹了jQuery中的$(window)與$(document)的用法區(qū)別,具體內(nèi)容大家可查看下文的詳細(xì)講解,感興趣的小伙伴們可以參考一下。2017-08-08jQuery學(xué)習(xí)筆記之創(chuàng)建DOM元素
這篇文章主要介紹了jQuery學(xué)習(xí)筆記之創(chuàng)建DOM元素的相關(guān)資料,需要的朋友可以參考下2015-01-01JavaScript揭秘:實(shí)現(xiàn)自動(dòng)化連連看游戲
這篇文章主要介紹了JavaScript揭秘:實(shí)現(xiàn)自動(dòng)化連連看游戲的相關(guān)資料,需要的朋友可以參考下2023-11-11