jquery 觸發/失去焦時間點事件例子詳解

來源:互聯網
上載者:User

標籤:http   io   ar   java   c   on   cti   代碼   r   

觸發焦點:

$("Element").focus()

觸發每一個匹配元素獲得焦時間點事件。

$("Element").focus(function)

事件會在獲得焦點的時候觸發,既可以是滑鼠行為,也可以是按tab鍵導航觸發的行為,並且綁定一個處理方法。


失去焦點:

$("Element").blur()

觸發每一個匹配元素失去焦時間點事件。

$("Element").blur(function)

事件會在元素失去焦點的時候觸發,既可以是滑鼠行為,也可以是按tab鍵離開的行為,並且綁定一個處理方法。

例子一

代碼如下 複製代碼
$(document).ready(function(){
$(".regbox .textb").bind("focus",function(){});
$(".regbox .textb").bind("blur",function(){});
$("input").css({"background-colo(www.111cn.net)r":"#fff3de"});
//if (screen.width>=1280){}else if (screen.width<1280){}


})

例子二

代碼如下 複製代碼
<script src="jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$(‘#username‘).focus(function ()//得到教室時觸發的時間
{
$(‘#username‘).val(‘‘);
})
$(‘#username‘).blur(function () 失去焦點時觸發的時間
{
if ($(‘#username‘).val() == ‘marry‘) {
$(‘#q‘).text(‘使用者名稱已存在!‘)
}
else { $(‘#q‘).text(‘ok!‘) }
})

from:http://www.111cn.net/wy/jquery/60507.htm

jquery 觸發/失去焦時間點事件例子詳解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.