focusout()是jQuery中的內置方法,用於從所選元素中移除焦點。句法:
$(selector).focusout(function);
參數:它接受參數“function”,該參數將在執行淡出方法後執行。
返回值:它返回失去焦點的選定元素。
jQuery代碼顯示focusout()方法的用法方式:
<html> 
  
<head> 
    <script 
    src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> 
    </script> 
    <!-- jQuery code to show the working of this method -->
    <script> 
        $(document).ready(function() { 
            $("div").focusin(function() { 
                $(this).css("background-color", "green"); 
            }); 
            $("div").focusout(function() { 
                $(this).css("background-color", "#FFFFFF"); 
            }); 
        }); 
    </script> 
    <style> 
        div { 
            border:2px solid black; 
            width:50%; 
            padding:20px; 
        } 
          
        input { 
            padding:5px; 
            margin:10px; 
        } 
    </style> 
</head> 
  
<body> 
    <!-- click inside the field focusin will take place and when  
                      click outside focusout will take place -->
    <div> 
        Enter name:
        <input type="text"> 
        <br> 
    </div> 
  
</body> 
  
</html>輸出:
在輸入字段中單擊後,focusin將起作用-

在輸入字段之外單擊後,焦點調整將生效。

相關用法
- JQuery jQuery.fx.interval用法及代碼示例
 - JQuery jQuery.support用法及代碼示例
 - JQuery jquery用法及代碼示例
 - JQuery jQuery.fx.off用法及代碼示例
 - jQuery :lt()用法及代碼示例
 - JQuery finish()用法及代碼示例
 - jQuery :first用法及代碼示例
 - JQuery one()用法及代碼示例
 - jQuery :last用法及代碼示例
 - JQuery is()用法及代碼示例
 - JQuery parentsUntil()用法及代碼示例
 
注:本文由純淨天空篩選整理自kundankumarjha大神的英文原創作品 jQuery | focusout() with Example。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
