After returning false, will all the following codes not be executed? Why does bbb still pop up when the button is clicked when the length is greater than 7?
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
window.onload=function(){
var oIpt1=document.getElementById('ipt1');
var oBtn1=document.getElementById('btn1');
oIpt1.onblur=function(){
if(oIpt1.value.length>7){
alert('aaa');
return false;
}
}
oBtn1.onclick=function(){
alert('bbb');
}
}
</script>
</head>
<body>
<input id="ipt1"></input>
<button id="btn1">提交</button>
</body>
</html>
return false is to jump out of the current function oIpt1.onblur and does not affect the execution of the external oBtn1.onclick function
That is the code after the current method will not be executed...
This is bound to the blur event. It has nothing to do with being bound to the click event
Define a variable to the outer function while returning. The internal one is false and the external one also changes to false. That’s OK