腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
首页
学习
活动
专区
工具
TVP
最新优惠活动
返回腾讯云官网
java大数据
专栏成员
举报
627
文章
461873
阅读量
29
订阅数
订阅专栏
申请加入专栏
全部文章(627)
java(253)
jsp(114)
javascript(91)
html(46)
编程算法(30)
大数据(30)
spring(24)
http(24)
maven(14)
servlet(13)
数据库(13)
ide(12)
eclipse(12)
git(11)
scala(9)
xml(9)
人工智能(8)
https(8)
网站(7)
css(6)
github(6)
svn(5)
网络安全(5)
spark(5)
hadoop(5)
面向对象编程(5)
sql(4)
神经网络(4)
开源(4)
anaconda(4)
php(3)
python(3)
node.js(3)
mvc(3)
mapreduce(3)
mybatis(3)
负载均衡(2)
tensorflow(2)
c++(2)
jquery(2)
api(2)
容器(2)
存储(2)
jdk(2)
卷积神经网络(2)
spring cloud(2)
windows(2)
微服务(2)
bash(1)
json(1)
android(1)
云数据库 SQL Server(1)
jar(1)
linux(1)
负载均衡缓存(1)
apache(1)
bash 指令(1)
yarn(1)
分布式(1)
运维(1)
shell(1)
ssh(1)
spring boot(1)
jdbc(1)
aop(1)
微信(1)
add(1)
area(1)
background(1)
branch(1)
commit(1)
directory(1)
document(1)
edit(1)
firebug(1)
function(1)
import(1)
int(1)
io(1)
list(1)
profile(1)
push(1)
repository(1)
rsa(1)
script(1)
spyder(1)
target(1)
text(1)
union(1)
var(1)
web(1)
width(1)
对象(1)
工具(1)
开发(1)
开发者(1)
浏览器(1)
模型(1)
搜索文章
搜索
搜索
关闭
javascript当中绑定事件和方法
jquery
8.绑定事件和方法 once, long time to know that "script" must be put in behind, while "input" must be put in front, otherwise document.getElementById("button1"); can not find the "button1",alert("button1 is "+ button1); 结果就是null,为什么这次跟往常我们的印象不一样了呢?因为往常我们先写一段script,之后在body中写上诸如<INPUT TYPE="button" onclick="abc",之类的话,这样上面的abc这样的代码开始不会被执行,里面的诸如document.getElementById ("button1");也就正确了。这里为什么跟往常不一样呢?因为要在一开始时,先给button绑上事件代码,否则button无事件响应。 例 8.1(commonEventPrerequisiteIEFF.html) <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <INPUT TYPE="button" NAME="button1" ID="button1" VALUE="单击我"/> <script> function testie() { alert("单击按钮ie"); } function testFF() { alert("单击按钮FireFox"); } /**/ /*obj.addEventListener("click",function(){func("看到我了吧");},false); the third argument is: A Boolean flag value that indicates whether the event listener should use bubbling (由里向外) or capture (由外向里) event propagation. 只要我们 知道第三个参数和事件冒泡有关就可以了。缺省值为假,即冒泡的意思。具体例子参考后面的事件冒泡例子。 */ var button1 = window.document.getElementById("button1"); alert("button1 is "+ button1); alert("document.all is" + document.all); alert(typeof(window.addEventListener) + " is typeof window.addEventListener"); alert(typeof(window.attachEvent) + " is typeof window.attachEvent"); alert(window.addEventListener + " is window.addEventListener"); alert(window.attachEvent + " is window.attachEvent"); if (typeof window.attachEvent === "object") { alert("ie"); button1.attachEvent("onclick", testie); } if (typeof window.addEventListener === "function") { alert("firefox"); button1.addEventListener("click", testFF, false); } // button1.addEventListener("click",test,false); //button1.attachEvent("onclick" , test); var str = ""; </script> 更多请见:https://blog.csdn.net/qq_43650923/article/details/102210095
马克java社区
2019-10-29
678
0
javascript当中抑制原始功能用法
jquery
http
7.抑制原始功能 例 7.1(PreventDefaulIEFF.html) <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <a id="kk" href="http://www.abc.com">淘宝</a>. <script> function Clicks(event) { var event = event || window.event; if (window.navigator.userAgent.indexOf("MSIE") >= 1) { event.returnValue = false; } else if ( window.navigator.userAgent.indexOf("Firefox") >= 1) { event.preventDefault(); } alert("链接被click"); } if (window.navigator.userAgent.indexOf("MSIE") >= 1) { document.getElementById("kk").attachEvent("onclick" , Clicks); } else if (window.navigator.userAgent.indexOf("Firefox") >= 1) { /*obj.addEventListener("click",function(){func("看到我了吧");},false); the third argument is: A Boolean flag value that indicates whether the event listener should use bubbling (由里向外) or capture (由外向里) event propagation. 只要我们 知道第三个参数和事件冒泡有关就可以了。缺省值为假,即冒泡的意思。具体例子参考后面的事件冒泡例子。 */ document.getElementById("kk").addEventListener("click", Clicks, true); } </script>
马克java社区
2019-10-21
403
0
没有更多了
社区活动
【纪录片】中国数据库前世今生
穿越半个世纪,探寻中国数据库50年的发展历程
立即查看
Python精品学习库
代码在线跑,知识轻松学
立即查看
博客搬家 | 分享价值百万资源包
自行/邀约他人一键搬运博客,速成社区影响力并领取好礼
立即体验
技术创作特训营·精选知识专栏
往期视频·千货材料·成员作品 最新动态
立即查看
领券
问题归档
专栏文章
快讯文章归档
关键词归档
开发者手册归档
开发者手册 Section 归档