javascript - I don't know much about JS. Ask a code question
phpcn_u1582
phpcn_u1582 2017-05-19 10:31:31
0
4
515

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>
phpcn_u1582
phpcn_u1582

reply all(4)
滿天的星座

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!