Avatar of 51501984
51501984
Flag for United Kingdom of Great Britain and Northern Ireland asked on

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

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

JavaScript

Avatar of undefined
Last Comment
51501984

8/22/2022 - Mon
Michel Plungjan

try
$('pulsate').click()
dorianm

You can place the call in the  tag like this :








Michel Plungjan

erm... oops
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
51501984

ASKER
OK Dorianm, tried that, still doesn't work I'm afraid
ASKER CERTIFIED SOLUTION
51501984

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.