dom-events

React - Prevent Event Trigger on Parent From Child

半城伤御伤魂 提交于 2020-04-07 13:50:28
问题 I have this scenario, where when parent element is clicked, it flips to show a child element with different colours. Unfortunately, when the user clicks on one of the colours, the 'click' event on parent is also triggered. How can I stop the event trigger on parent when the child is clicked? Possible solutions I am wondering: CSS ? Append pointer-events : none class to the parent when the child is clicked. However, this would mean that the parent will need to be cleansed of the pointer-events

React - Prevent Event Trigger on Parent From Child

假装没事ソ 提交于 2020-04-07 13:47:56
问题 I have this scenario, where when parent element is clicked, it flips to show a child element with different colours. Unfortunately, when the user clicks on one of the colours, the 'click' event on parent is also triggered. How can I stop the event trigger on parent when the child is clicked? Possible solutions I am wondering: CSS ? Append pointer-events : none class to the parent when the child is clicked. However, this would mean that the parent will need to be cleansed of the pointer-events

Getting Null value when page content reload

萝らか妹 提交于 2020-03-25 13:51:38
问题 Trying to create Chrome extension where it deletes particular elements from the third party website. I'm getting an issue I want to remove a class element by getting an element by ID on the third party website and it run successfully when the whole website reload. But when the only page content update then they find the null value. Please Note The whole page does not reload only the contents of the page reload. Other items stay same like Heading, Descriptions, etc are same but only the

In JavaScript, for text to speech, when the voiceschanged event was being listened to, nothing happened with an array of voices? [duplicate]

爷,独闯天下 提交于 2020-03-02 07:52:06
问题 This question already has answers here : Getting the list of voices in speechSynthesis (Web Speech API) (11 answers) Closed last month . Related to this text to speech question, I have the following code: First of all, I am not sure if this is the best way to write the code, because it is initializing, and then setting a listener to "call itself". (seems a little bit hacky). Second, although the listeners got "notified", the voices.length is still 0 . Nothing really happens with an array of

Javascript/html5 play multiple audio files or overlap audio

為{幸葍}努か 提交于 2020-02-28 07:51:58
问题 Let me start by saying I am trying to play a mp3 file whenever the player collides with a wall, simple enough and done. But I wish to have another sound file play when the player hits another wall. I have tried using both <audio> tag in the html file, than playing it in Javascript: var sound = document.getElementById("TheHtml5Tag"); Still the same issue, only one sound can be played, the next sound won't play untill the first one is finished. Even when using multiple <audio> tags and multiple

MouseEvent.offsetX/Y resets to 0 if moving over different child elements

我的梦境 提交于 2020-02-25 09:52:05
问题 Take the following fiddle. It contains a parent div with 3 child divs. A click-listener is attached to the parent div and should throw alerts with the mouse position relative to the parent div: const parent = document.getElementById('main'); parent.addEventListener('click', handleMouseClick); function handleMouseClick(e) { alert(e.offsetX, e.offsetY); } What I expect: Click on any of the child divs and get the click position relative to the parent div (#main). What actually happens: OffsetX/Y

Listening for variable changes in JavaScript

为君一笑 提交于 2020-02-04 05:36:46
问题 Is it possible to have an event in JS that fires when the value of a certain variable changes? JQuery is accepted. 回答1: Yes, this is now completely possible! I know this is an old thread but now this effect is possible using accessors (getters and setters): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters You can define an object like this, in which aInternal represents the field a : x = { aInternal: 10, aListener: function(val) {

Running a method on browser close tab or browser exit

百般思念 提交于 2020-02-02 07:49:45
问题 Is there an action handler I can use in Javascript+Angular+JQuery that makes it possible to schedule a method to be executed just before a tab is closed in the web browser? By close I mean quitting the browser or closing the tab or crashing or anything... 回答1: Yeah, you just bind the the beforeunload on the window object. angular.element($window).bind("beforeunload", exitHandler) 来源: https://stackoverflow.com/questions/19287644/running-a-method-on-browser-close-tab-or-browser-exit

Running a method on browser close tab or browser exit

女生的网名这么多〃 提交于 2020-02-02 07:48:41
问题 Is there an action handler I can use in Javascript+Angular+JQuery that makes it possible to schedule a method to be executed just before a tab is closed in the web browser? By close I mean quitting the browser or closing the tab or crashing or anything... 回答1: Yeah, you just bind the the beforeunload on the window object. angular.element($window).bind("beforeunload", exitHandler) 来源: https://stackoverflow.com/questions/19287644/running-a-method-on-browser-close-tab-or-browser-exit

Owl carousel 2 cloned item click events not firing

可紊 提交于 2020-01-30 08:24:25
问题 I'm currently using Owl Carousel 2.0.0-beta.2.4 in development to keep the carousel centered and loop the items which works nicely. For some reason the cloned items that Owl generates when setting loop: true doesn't seem to fire on click. You will see in the example I've put together below that every other item alerts the click when fired but if the item has been cloned it doesn't seem to register the click event. JSFiddle HTML: <div id="multiple-carousel" class="carousel-style owl-carousel">