javascript-events

How to use getEventListeners in Chrome Dev Tool?

那年仲夏 提交于 2020-01-22 17:28:46
问题 I tried to trace back which function hooked into a click event of .someclass . I open Chrome Dev Tool and type this getEventListeners(document.querySelector('.someclass')); The result is this Object {} I cannot click and open it to find out the name of the object or the source code that handle click event. Is there a way to find out? UPDATE 1: Followed Krasimir's advise below. There could be only two events: mousemove or mouseover . So how do I find out the exact function handling that event

Disable Predictive Scrolling - Mousewheel (OnScroll) Event fires too often (Touchpad) - JS

随声附和 提交于 2020-01-22 12:24:44
问题 I am executing javascript onScroll. My code works great with any normal computer mouse, but when i use my notebooks touchpad, i encounter the following situation: my mouse fires (about 1 to 8) mousewheel events while the finger is moving the wheel. my touchpad fires a lot more (~60) mousewheel events while the two fingers are touching the pad and continues to fire after my fingers are up in the air again. I know this behavior from mobile touch devices. The Feature is called "Predictive Touch"

Setting event handlers using a for loop [duplicate]

陌路散爱 提交于 2020-01-22 02:51:08
问题 This question already has answers here : How to generate event handlers with loop in Javascript? [duplicate] (3 answers) Closed 6 years ago . I was messing around with some javascript, on jsfiddle, and ran into a strange issue. I can't seem to figure out why I am unable to set onclick event handlers via a for loop: html: <table border="1" cellspacing="1" width="500"> <tr id="headerRow"> <td>Header1</td> <td>Header2</td> <td>Header3</td> <td>Header4</td> </tr> <tr> <td>books</td> <td>red</td>

I trying to get the target element's id when function fired, but `this` keyword returns `undefined`

时光总嘲笑我的痴心妄想 提交于 2020-01-21 19:44:10
问题 I trying to capture the target element's id when function fired, but this keyword returns undefined --- HTML file. --- (I can't add any parameter in onclick function) I have many <a> tag in the page and want to identify witch <a> tag was clicked. <a href="#some_links" id="element_id" onclick = "object.pageName.functionName('parms1', 'parms2', 'parms3')">Get this object</a> <a href="#some_links" id="second_element_id" onclick = "object.pageName.functionName('parms1', 'parms2', 'parms3')">Get

I trying to get the target element's id when function fired, but `this` keyword returns `undefined`

浪尽此生 提交于 2020-01-21 19:40:46
问题 I trying to capture the target element's id when function fired, but this keyword returns undefined --- HTML file. --- (I can't add any parameter in onclick function) I have many <a> tag in the page and want to identify witch <a> tag was clicked. <a href="#some_links" id="element_id" onclick = "object.pageName.functionName('parms1', 'parms2', 'parms3')">Get this object</a> <a href="#some_links" id="second_element_id" onclick = "object.pageName.functionName('parms1', 'parms2', 'parms3')">Get

Higher Order React Component for Click Tracking

与世无争的帅哥 提交于 2020-01-21 11:13:14
问题 I'd like to implement a higher order react component which can be used to easily track events (like a click) on any React component. The purpose of this is to easily hook clicks (and other events) into our first party analytics tracker. The challenge I've come across is that the React synthetic event system requires events (like onClick ) be bound to react DOM elements, like a div . If the component I'm wrapping is a custom component, like every HOC implemented via a higher order function is,

Higher Order React Component for Click Tracking

可紊 提交于 2020-01-21 11:12:58
问题 I'd like to implement a higher order react component which can be used to easily track events (like a click) on any React component. The purpose of this is to easily hook clicks (and other events) into our first party analytics tracker. The challenge I've come across is that the React synthetic event system requires events (like onClick ) be bound to react DOM elements, like a div . If the component I'm wrapping is a custom component, like every HOC implemented via a higher order function is,

how to stop element with first onclick event to be fired when enter key is pressed first time

流过昼夜 提交于 2020-01-21 09:54:08
问题 I was fixing a bug in a jsp page in which even though a function is defined with onkeypress event to click a particular button(actually its an image of button with onclick property associated with it) when the page is opened first time and then enter key is pressed its throwing an error. When i debugged the code then i find out that actually two calls are made simultaneously ie the first button with onclick property is also clicked. Here is just a sample code <html> <head> </head> <body> <div

how to stop element with first onclick event to be fired when enter key is pressed first time

僤鯓⒐⒋嵵緔 提交于 2020-01-21 09:53:47
问题 I was fixing a bug in a jsp page in which even though a function is defined with onkeypress event to click a particular button(actually its an image of button with onclick property associated with it) when the page is opened first time and then enter key is pressed its throwing an error. When i debugged the code then i find out that actually two calls are made simultaneously ie the first button with onclick property is also clicked. Here is just a sample code <html> <head> </head> <body> <div

Invoke the default action of a specific event on an object

天大地大妈咪最大 提交于 2020-01-21 07:56:09
问题 I want a generic (cross browser) way to get the browser to execute the default action for an object for a specified event preferably without getting any attached listeners to fire . This kind of question has been asked before but in the context of already being in an event, &/or strictly talking about synchronously holding off the default action before letting it happen later. Basically, let's say you have an DOM element (you don't know which) variable, and you want to invoke a click , such