Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  142] [ 1]  / answers: 1 / hits: 115538  / 11 Years ago, wed, may 22, 2013, 12:00:00

The following code (see Fiddle here) throws the stack overflow referred to in the question title. I'm trying to get a box shadow to display around a circular image in a pulse effect. Can anyone point out the recursion, please? I'm very much a Javascript novice and can't see it. Thank you.



HTML



<div id=pulseDiv> 
<a href=# id=advisers-css-image>
<div id=advisersDiv><img src=http://ubuntuone.com/1djVfYlV62ORxB8gSSA4R4></div>
</a>
</div>


CSS



.pulse { box-shadow: 0px 0px 4px 4px #AEA79F; }


Javascript



function fadeIn() {
$('#pulseDiv').find('div.advisersDiv').delay(400).addClass(pulse);
fadeOut();
};

function fadeOut() {
$('#pulseDiv').find('div.advisersDiv').delay(400).removeClass(pulse);
fadeIn();
};

More From » jquery

 Answers
31

Your calls are made recursively which pushes functions on to the stack infinitely that causes max call stack exceeded error due to recursive behavior. Instead try using setTimeout which is a callback.


Also based on your markup your selector is wrong. it should be #advisersDiv


Demo


function fadeIn() {
$('#pulseDiv').find('div#advisersDiv').delay(400).addClass("pulse");
setTimeout(fadeOut,1); //<-- Provide any delay here
};

function fadeOut() {
$('#pulseDiv').find('div#advisersDiv').delay(400).removeClass("pulse");
setTimeout(fadeIn,1);//<-- Provide any delay here
};
fadeIn();

[#78086] Tuesday, May 21, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
daquanmilesw

Total Points: 57
Total Questions: 102
Total Answers: 110

Location: Wallis and Futuna
Member since Sat, Aug 6, 2022
2 Years ago
daquanmilesw questions
;