Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
34
rated 0 times [  38] [ 4]  / answers: 1 / hits: 5357  / 10 Years ago, sun, march 30, 2014, 12:00:00

When we use alert(), some times the code breaks.



For example:



HTML:



<span>Hi</span>


Javascript:



$(document).ready(function () {

$(span).dblclick(function () {
alert(b);
});
$(span).click(function () {
alert(a);
});

});


The alert(b) doesn't even show up.



But if we change both the alert() to console.log, it is logged.



Alert Demo & console.log Demo



So, what's happening?


More From » alert

 Answers
2

alert opens a model dialogue. When it is open, you can't interact with any part of the page except the alert itself.



Since you can't interact with the page, the second half of the double click can't reach the span, so the double click event won't fire.


[#46431] Saturday, March 29, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
agustindejonm

Total Points: 738
Total Questions: 84
Total Answers: 84

Location: Northern Ireland
Member since Mon, Nov 14, 2022
2 Years ago
agustindejonm questions
Fri, Jun 25, 21, 00:00, 3 Years ago
Fri, Sep 18, 20, 00:00, 4 Years ago
Sat, May 16, 20, 00:00, 4 Years ago
;