没有jquery,jquery的'trigger'方法相当于什么? [英] what's the equivalent of jquery's 'trigger' method without jquery?

查看:113
本文介绍了没有jquery,jquery的'trigger'方法相当于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有 jQuery jQuery 触发器方法相当于什么?

what's the equivalent of jQuery's trigger method without jQuery?

例如,我如何做 $('。blah')。触发器('click'); 而不用 jQuery

e.g., how do i do something like $('.blah').trigger('click'); without jQuery?

推荐答案

对于非常伪劣的等价物的某些价值:

For some value of "a very shoddy equivalent":

var button = document.getElementById("thebutton")
button.click()

并非所有浏览器(例如Firefox!)都以这种方式允许模拟事件!使用 onclick()仅在事件符合内联时才有效。

Not all browsers (e.g. Firefox!) allow simulated events this way! Using onclick() only works if the event is in-line, etc.

请参阅 jQuery源并搜索trigger:(第一场比赛)以查看完成的所有icky内容让它工作(其中很多只是围绕jQuery内部进行调整,其他框架使得有更简单的例子)。

Please see the jQuery source and search for "trigger:" (first match) to see all the icky stuff done to "make it work" (a good bit of it is just munging around the jQuery internals, other frameworks make have much simpler examples).

快乐编码。

这篇关于没有jquery,jquery的'trigger'方法相当于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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