Html
user name:<input type=”text” id=”name”><br><br>
<button id=”btn”>click</button>
Blur() function is used for current element focus removing.
JavaScript blur() method
example 1
<script type=”text/javascript”>
$(‘#name’).blur(function(){
let name=document.getElementById(‘name’).value;
alert(name);
});
</script>
example 2
html
<div id=”box”>
user name:<input type=”text” id=”name”><br><br>
<button id=”btn”>click</button>
</div>
JavaScript
<script type=”text/javascript”>
$(‘#name’).blur(function(){
$(‘#box’).css(‘background-color’,’red’);
});
</script>
example 3
html
<div id=”box”>
user name:<input type=”text” id=”name”><br><br>
<button id=”btn”>click</button>
</div>
JavaScript
<script type=”text/javascript”>
$(‘#name’).blur(function(){
$(‘#btn’).css(‘background-color’,’aqua’);
});
</script>