Javascript event simulation library

跟風遠走 提交于 2019-12-18 09:28:05

问题


Do you know a JS library for DOM events simulation? I know that this operation can be done but i can't find any library to do it.

UPDATE: I try to explain better my question. Javascript can simulate events like the user click, i'm looking for a library that helps me with this operation.


回答1:


Kangax made a very useful set of extensions for the PrototypeJS framework, the one that might interest you is Event.simulate




回答2:


http://developer.yahoo.com/yui/3/event/#eventsimulation

""" Simulated events are browser-created events that, most of the time, behave exactly as user-initated events. Events bubble as they normally would and event objects are created with properties containing data about the event (sometimes these properties are browser-specific, so it's recommended that you make use of the browser-equalizing methods of Y.Event to retrieve the appropriate values for properties such as target, relatedTarget, and charCode. All event handlers are called synchronously at each event target throughout the event's lifetime. Events are simulated using the simulate() method on any Y.Node instance. """




回答3:


All of the major javascript libraries have the ability to trigger events. To add to the chorus of examples, in jquery you do it with: $("target_element").trigger("an_event");




回答4:


You can use prototype.js to fire your own custom events

e.g. treeContainer.fire('nodeIcon:mousedown', {targetEvent: event, node: node});



来源:https://stackoverflow.com/questions/2524697/javascript-event-simulation-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!