複製鏈接
請複製以下鏈接發送給好友

onblur 事件

鎖定
onblur事件(Onblur event),計算機術語,是指會在對象失去焦點時發生。 [1] 
中文名
onblur 事件
外文名
Onblur event
適用領域
計算機
所屬學科
計算機學科

onblur 事件語法

onblur="SomeJavaScriptCode"

onblur 事件支持的HTML標籤

<a>, <acronym>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <button>, <caption>, <cite>, <dd>, <del>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <frame>, <frameset>, <h1> to <h6>, <hr>, <i>, <iframe>, <img>, <input>, <ins>, <kbd>, <label>, <legend>, <li>, <object>, <ol>, <p>, <pre>, <q>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

onblur 事件支持的JS對象

button, checkbox, fileUpload, layer, frame, password, radio, reset, submit, text, textarea, window

onblur 事件onblur 事件參數

onblur 事件具有下表中的參數: [2] 
參數
描述
SomeJavaScriptCode
必需。規定該事件發生時執行的 JavaScript。

onblur 事件實例

本例實現的功能是:當文本輸入框失去焦點(即在文本框中的光標閃動時,用鼠標單擊網頁中別的地方,或使用Tab鍵切換焦點所引發的事件)時,文本輸入框中的每一個英文字母都將被轉換成大寫字母。
<html>
    <head>
        <script type="text/javascript">
        function upperCase(){
            var x=document.getElementById("fname").value;
            document.getElementById("fname").value=x.toUpperCase();
        }
        </script>
    </head>
    <body>
        輸入您的姓名:<input type="text" id="fname" onblur="upperCase();" />
    </body>
</html>
以上代碼實測通過
參考資料