JavaScript onblur event
The JavaScript onblur event ( event ) is used to monitor the out-of-focus situation of the element. Out-of-focus means the loss of focus. The browser determines that the original element is out of focus when the user’s mouse cursor focuses on other elements . For example , When a netizen fills in one of the fields in the membership form, it will naturally jump to the next field to continue filling in after it is completed, whether using the Tab key on the keyboard or using the mouse to move the cursor to the next field. Even if the field originally filled in is out of focus, if the designer inserts an onblur event in the field originally filled in, a specific JavaScript function can be triggered to do some work. The standard way of writing onblur event is to use all lowercase English, not recommended Written as onBlur. JavaScript onblur event syntax
onblur="javascript function to be triggered"
onblur can be used in many web page elements, common applications such as text input fields input text , textarea, etc. The job of onblur is to "judge whether a netizen has caused an out-of-focus action on an element". When a situation occurs, onblur must Trigger the JavaScript function to execute other code, and the work of onblur is complete.
JavaScript onblur event example
function ShowName(){
alert('Your name is:'+document.getElementById("MyName").value);
}
</script>
Please enter your name: <input type="text" onblur="ShowName()" id="MyName"><br>
Please enter your interest: <input type="text">
Please enter your interest:
Post a Comment
0 Comments