We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<input type="button" onclick="alert('按钮被点击1')" value="按钮1" /> <input type="button" value="按钮2" id="button2" /> <input type="button" value="按钮3" id="button3" /> <script> function addEvent(obj,type,handle){ try{ // Chrome、FireFox、Opera、Safari、IE9.0及其以上版本 obj.addEventListener(type,handle,false); }catch(e){ try{ // IE8.0及其以下版本 obj.attachEvent('on' + type,handle); }catch(e){ // 早期浏览器 obj['on' + type] = handle; } } } var button2 = document.getElementById('button2'); button2.onclick = function() { alert('按钮被点击2'); } var button3 = document.getElementById('button3'); addEvent(button3,'click',function(){ alert('按钮被点击3'); }) </script>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1. 继承与原型链
2. javascript事件绑定方式
3. 跨域解决方案
4. var let和const的区别
参考文章
5. 箭头函数和普通函数的区别
参考文章
6. class怎么实现私有属性和方法
The text was updated successfully, but these errors were encountered: