欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

jquery獲取焦點(diǎn)事件,jQuery獲取焦點(diǎn)

jquery一個(gè)div怎么獲得焦點(diǎn)和失去焦點(diǎn)

DIV獲取焦點(diǎn)(兩種方法):

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、成都微信小程序、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了黃平免費(fèi)建站歡迎大家使用!

DIV直接使用focus()和blur()兩個(gè)方法是無效的,需添加tabindex="0"或者contenteditable="true"屬性

①:設(shè)置div為可編輯狀態(tài),則可點(diǎn)擊獲取焦點(diǎn),同時(shí)div的內(nèi)容也是可以編輯的;如:

div

contenteditable="true"11111111111111/div

②:設(shè)置div的tabindex,此時(shí)div的內(nèi)容是不可編輯的;如:

div

tabindex="0"11111111111111/div

PS:設(shè)置tabindex屬性,按鍵盤Tab鍵可讓其獲取焦點(diǎn),其中tabindex的值越小在tab鍵切換的時(shí)候就會首先聚焦

js jQuery 觸發(fā)獲取焦點(diǎn)

$('input[name="name"]').on('input?propertychange',?function(event)?{

var?_this?=?$(this);

var?vals?=?_this.val();

if(vals!=''){

setTimeout(function(){

_this.next().focus();

},1000)

}

});

jquery獲取焦點(diǎn)問題

script type="text/javascript"

$(function() {

// 點(diǎn)擊 "彈出層" 在頁面建立 div 層

$("#open").on("click", function() {

$("body").append('div id="popup" style="width: 100px; height: 100px; background: #eee; padding: 20px;"p文字文字文字/pinput type="button" id="ok" value="確定" /input type="button" id="cancel" value="取消" //div');

// 確認(rèn) 按鈕獲取焦點(diǎn)

$("#ok").focus();

});

$(document).on("click", "#ok", function() {

alert("通過點(diǎn)擊 確定 關(guān)閉層");

$("#popup").remove();

}).on("click", "#cancel", function() {

alert("通過點(diǎn)擊 取消 關(guān)閉層");

$("#popup").remove();

}).on("keydown", function(e) {

if(e.which === 13) {

alert("通過鍵盤 回車 關(guān)閉層");

$("#popup").remove();

}

else if(e.which === 27) {

alert("通過鍵盤 ESC 關(guān)閉層");

$("#popup").remove();

}

});

});

/script

input type="button" id="open" value="彈出層" /

你可以根據(jù)不同事件(鼠標(biāo)點(diǎn)擊 確認(rèn)/取消,鍵盤按下 回車/ESC)在 .remove() 之前添加更多代碼。

jquery js 當(dāng)文本框獲得焦點(diǎn)時(shí),自動(dòng)選中里面的文字

$(function(){

$(":text").focus(function(){

this.select();

});

});

JQuery文本框獲得焦點(diǎn)背景顏色改變:

1.先使用jQuery選擇器找到所有的文本框。

2.為文本框注冊獲得焦點(diǎn)事件,即focus事件。

3.在焦點(diǎn)事件的事件處理函數(shù)中對當(dāng)前得到焦點(diǎn)的文本框設(shè)置背景色。

4.注冊失去焦點(diǎn)事件,即blur事件。

5.在失去焦點(diǎn)的事件處理函數(shù)中對當(dāng)前觸發(fā)事件的文本框改變背景顏色。

script type="text/javascript"

$(function(){

//找到文本框,并注冊得到焦點(diǎn)事件。

$("input:text").focus(function(){

//讓當(dāng)前得到焦點(diǎn)的文本框改變其背景色。

$(this).css("background","pink");

});

//找到文本框,并注冊失去焦點(diǎn)事件

$("input:text").blur(function(){

//讓當(dāng)前失去焦點(diǎn)的文本框背景色變?yōu)榘咨?/p>

$(this).css("background","white");

});

});

/script

網(wǎng)頁題目:jquery獲取焦點(diǎn)事件,jQuery獲取焦點(diǎn)
文章源于:http://chinadenli.net/article4/dsdejoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站營銷Google、自適應(yīng)網(wǎng)站定制網(wǎng)站、軟件開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)