Home > Web Front-end > JS Tutorial > How to overwrite the original method in js to achieve rewriting_javascript skills

How to overwrite the original method in js to achieve rewriting_javascript skills

WBOY
Release: 2016-05-16 16:37:04
Original
1430 people have browsed it
<font face="Arial" style="background-color: #ffffff"><</font>html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script>
function myblur () {
alert("1、离开");
}
function bindEvent(func){
myblur = func;
}
function myonclick() {
bindEvent(function(){
alert("天啊!myblur方法被覆盖了!");
});
}
</script>
</head>
<body>
<input type="text" onblur="myblur()" value="光标选中然后光标离开会调用myblur()方法"/>
<input type="button" onclick="myonclick()" value="覆盖myblur()" />
注:覆盖myblur()后,再次光标选中输入框然后再离开
</body>
</html>
Copy after login

Purpose: Improve the perfect calling method.

If you make an editor that provides some cursor leave events, etc., it is best to use this method to operate, because when others use your editor, you may need to use the event methods provided by the editor to handle some Some events need to be rewritten according to special requirements. Therefore, in this case, it is necessary to provide event methods that allow overriding of the event methods provided by the editor!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template