基于jquery實現(xiàn)的移入頁面上空文本框時,讓它變?yōu)榻裹c,移出清除焦點
更新時間:2011年07月26日 20:19:45 作者:
基于jquery實現(xiàn)的移入頁面上空文本框時,讓它變?yōu)榻裹c,移出清除焦點的實現(xiàn)代碼。
復(fù)制代碼 代碼如下:
var Page_INIT = function () {
$(document).bind("mouseover", function (e) {//鼠標(biāo)移入
if (e.target.tagName.toUpperCase() == "INPUT") {
var input = e.target;
if (input.type == "text") {//如果是文本框
if (window.Page_FocusTimer) {//如果處于焦點狀態(tài)
window.clearTimeout(window.Page_FocusTimer);//清除焦點狀態(tài)
}
window.Page_FocusTimer = window.setTimeout(function () { //每0.2豪秒去執(zhí)行這個匿名方法一次
if (!input.value) {//如果內(nèi)容為空,則設(shè)為焦點
try {
input.focus();
} catch (e) { }
}
}, 200);
}
}
}).bind("mouseout", function (e) {//鼠標(biāo)移出
if (e.target.tagName.toUpperCase() == "INPUT") { //被處理的事件源對象它的名稱(即HTML標(biāo)記)轉(zhuǎn)為大寫后如果是INPUT
var input = e.target;
if (input.type == "text") {
if (window.Page_FocusTimer) {
window.clearTimeout(window.Page_FocusTimer);
}
}
}
});
}
相關(guān)文章
jquery調(diào)整表格行tr上下順序?qū)嵗v解
這篇文章主要為大家介紹了jquery調(diào)整表格行tr上下順序?qū)嵗?,具有一定的參考價值,感興趣的朋友可以參考一下2016-01-01
jQuery對象和DOM對象的相互轉(zhuǎn)化實現(xiàn)代碼
jQuery對象就是通過jQuery包裝DOM對象后產(chǎn)生的對象。jQuery對象是jQuery獨有的,其可以使用jQuery里的方法,但是不能使用DOM的方法;例如$("#img").attr("src","test.jpg"); 這里的$("#img")就是jQuery對象;2010-03-03
jQuery實現(xiàn)網(wǎng)頁抖動的菜單抖動效果
這篇文章主要介紹了jQuery實現(xiàn)網(wǎng)頁抖動的菜單抖動效果,鼠標(biāo)滑過菜單項可見到菜單項的抖動效果,涉及jquery鼠標(biāo)事件及頁面元素樣式動態(tài)操作的技巧,需要的朋友可以參考下2015-08-08

