onclick或onClick? [英] onclick or onClick?

查看:80
本文介绍了onclick或onClick?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为在javascript中绑定click事件是通过使用 node.onclick 完成的,而Chrome / Firefox似乎同意我,但我看到它写的 .onClick 这里由4人共4次,所以它不能成为一个错字,我怀疑这是巧合。

I thought that binding the click event in javascript is done by using node.onclick, and Chrome/Firefox seem to agree with me, but I saw it written .onClick here 4 times by 3 people, so it can't be a typo and I doubt that it's a coincidence.

那么,为什么人们写 onClick 当它不起作用?

So, why are people writing onClick when it does not work?

UPDATE :有两个很好的解释;我不知道哪一个是最合理的,所以我明天会接受基于民众投票的答案。

UPDATE: There are two good explanations; I don't know which one of them is the most plausible, so I will accept the answer based on popular vote, tomorrow.

推荐答案

因为某些浏览器(取决于DOCTYPE)能够容忍内联 onClick =something();属性...它似乎已经传播有点,甚至是JavaScript问题,它不起作用,因为案件很重要。

Because some browsers (depending on the DOCTYPE) are tolerant of the inline onClick="something();" attribute...it seems to have spread a bit, even into JavaScript questions where it doesn't work, since case matters.

另外,特别是对于stackoverflow ...人们在问题中使用它... ,大多数时候,如果他们的代码有效,他们就不会问一个问题:)

Also, specifically to stackoverflow...people using it in questions...well, most of the time they wouldn't be asking a question if their code worked :)

这篇关于onclick或onClick?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆