We help IT Professionals succeed at work.

Jquery load problem, unable to trigger a function on page load

51501984
51501984 asked
on
2,203 Views
Last Modified: 2009-12-16
I'm using someone's Jquery code to make a page element pulse. the code works absolutely fine if I want the element to pulse when it is clicked upon but I cannot figure out how to trigger the function when the page loads (i.e. it just starts pulsing you don't have to click on it)

I'm sure it's very straight forward, but I'm new to Jquery and I can't figure it out; I thought replacing click with load would do it but alas no.

The original demo is here:

http://ui.jquery.com/repository/real-world/effects/


$(document).ready(function() {
	
	$("div.effect")
		.hover(function() {
			$(this).addClass("hover");
		}, function() {
			$(this).removeClass("hover");
		})
		;
	
	
	var effect = function(el, n, o) {
		
		$.extend(o, {
			easing: "easeOutQuint"
		});
		
		$(el).bind("click", function() {
			
			$(this).addClass("current").hide(n, o, 1500, function() {
				var self = this;
				window.setTimeout(function() {
					$(self).show(n, o, 1500, function() { $(this).removeClass("current"); });
				},500);
			});
		});
		
	};
	
 
 
	
	effect("#pulsate", "pulsate", { times: 4 });
 
	
	$("#transfer").bind("click", function() { $(this).addClass("current").effect("transfer", { to: "div:eq(0)" }, 1000, function() { $(this).removeClass("current"); }); });
	
});
 
 
on the page:
 
		<div class="effect" id="pulsate">
		<p>Pulsate 2 times</p>
		</div>
 
like i say it works when it's clicked on but I would like to work automatically when the page loads.

Open in new window

Comment
Watch Question

Michel PlungjanIT Expert
CERTIFIED EXPERT
Top Expert 2009

Commented:
try
$('pulsate').click()

Commented:
You can place the call in the  tag like this :








Michel PlungjanIT Expert
CERTIFIED EXPERT
Top Expert 2009

Commented:
erm... oops

Author

Commented:
OK Dorianm, tried that, still doesn't work I'm afraid
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.