javascript-events

Is there a way to fire over events ignoring z-index?

独自空忆成欢 提交于 2019-12-18 13:35:27
问题 If I have something like this: Is there a way to fire the mouseover events on BOTH divs? Edit: Sorry all .. I tried to simplfy the problem so it was clear to understand and I forgot to mention I have more than 100 divs like that so probably those solutions don't work. I'm going to see if I can adpat them. Many thanks everybody anyway. 回答1: I put together a working example here with JSFiddle: http://jsfiddle.net/gfosco/CU5YT/ It's similar to madeinstefanos answer, but specific to your example.

window.resize in jquery firing multiple times

匆匆过客 提交于 2019-12-18 13:07:37
问题 I have the following javascript/jquery code in an HTML file: <html> <head> <script src="http://code.jquery.com/jquery-1.6.2.min.js" type="text/javascript"></script> <script language="javascript"> $(window).resize(function(){alert('hi');});</script> </head> <body> resize me </body> </html> It appears relatively straight forward, however when I re size the browser window, I get two successive alert windows on Chrome and IE9 and I seemingly crash FF5. What am I missing? Is it one fire per

How to detect `focusin` support?

喜你入骨 提交于 2019-12-18 12:21:39
问题 Thanks to Perfection kills, we can use the following JavaScript to detect event support: function hasEvent(ev) { var elem = document.createElement('a'), type = 'on' + ev, supported = elem[type] !== undefined; if (!supported) { elem.setAttribute(type, 'return;'); supported = typeof elem[type] === 'function'; } elem = null; return supported; } This works for about the only time I need it: detecting mouseenter support; hasEvent('mouseenter') will return false in Chrome, Firefox, etc., as it

JavaScript: SyntaxError: missing ) after argument list [closed]

只愿长相守 提交于 2019-12-18 12:06:17
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . I am getting the error: SyntaxError: missing ) after argument list With this javascript: var nav = document.getElementsByClassName('nav-coll'); for (var

Add days to date using javascript

谁说胖子不能爱 提交于 2019-12-18 11:53:54
问题 I am trying to add days to a given date using javascript. I have the following code function onChange(e) { var datepicker = $("#DatePicker").val(); alert(datepicker); var joindate = new Date(datepicker); alert(joindate); var numberOfDaysToAdd = 1; joindate.setDate(joindate + numberOfDaysToAdd); var dd = joindate.getDate(); var mm = joindate.getMonth() + 1; var y = joindate.getFullYear(); var joinFormattedDate = dd + '/' + mm + '/' + y; $('.new').val(joinFormattedDate); } On first alert i get

Chrome (maybe Safari?) fires “blur” twice on input fields when browser loses focus

半腔热情 提交于 2019-12-18 11:49:43
问题 Here is an interesting jsfiddle. In Firefox: Run the fiddle Click in text input Click somewhere else. Should say "1 blurs". Click in the text input again. ALT-TAB to another window. Fiddle should now say "2 blurs". In Chrome, at step 5, it says "3 blurs". Two separate "blur" events are fired when the whole browser loses focus. This is of interest because it means that it's not safe to assume, in a "blur" handler, that the element actually had focus just before the event was dispatched; that

How to add an onchange event to a select box via javascript?

人盡茶涼 提交于 2019-12-18 11:41:49
问题 I've got a script where I am dynamically creating select boxes. When those boxes are created, we want to set the onchange event for the new box to point to a function called toggleSelect(). I can't seem to get the syntax right to create the onchange event. Can someone tell me what I'm doing wrong? It doesn't throw an error, but doesn't work, either. col = dataRow.insertCell(0); var transport_select = document.createElement('select'); transport_select.id = transport_select_id; transport_select

Single thread concept of JavaScript running in browser

浪尽此生 提交于 2019-12-18 11:29:13
问题 The following figure is taken from Chapter 3 of the book Secrets of the JavaScript Ninja by Jon Resig. Here the author is explaining the browser event loop. The book has to say this : It’s important to note that the browser mechanism that puts the events onto the queue is external to this event loop model. The processing necessary to determine when events have occurred and to push them onto the event queue doesn’t participate in the thread that’s handling the events. So my question is it

Jquery on hover not working

强颜欢笑 提交于 2019-12-18 11:08:07
问题 I'm changing my codes to be compatible with jQuery 1.8 and I'm stuck with this hover which doesn't work. When I used then same thing with a click it worked. Here is my code, can anyone tell me where I'm going wrong? $(document).on('hover', '.top-level', function (event) { $(this).find('.actionfcnt').show(); $(this).find('.dropfcnt').show(); }, function () { $(this).find('.dropfcnt').hide('blind', function () { $('.actionfcnt').hide(); }); }); 回答1: Deprecated as of jQuery 1.8 : The name "hover

Dynamically Adding Elements and trying to use the selectors .click event Jquery

半世苍凉 提交于 2019-12-18 09:45:24
问题 I'm trying to dynamically add elements and have click listeners for them in JQuery. For whatever reason the removeGroup event does not get set off when I click on an elements 'remove' button. Any help would be great, thanks. $('.removeGroup').click(function(event){ alert(); }); cartPopper.click(function(event){ $('#selectedGroupList').find('.selected').remove(); for(group in selectedGroups) { var group_id = selectedGroups[group]; var name = $('.' + group_id).text(); $('#selectedGroupList')