anybody knows an easy way to display an alert after each 50 seconds in jquery (infinite loop)
Use setInterval(), like this:
setInterval(function() {
alert('hi!');
}, 50000);
Note this is just JavaScript, no jQuery library needed.
I assume you have a purpose, not actually alerting? :) Please let that be the case!
Related
I need the javascript code for tooltip to appear onclick for 10 seconds
Mostly Without using html code, or any plugins
$('a.pet_type_link').click(function() {
//I need tooltip to appear for 10seconds
});
I am using coffescript and haml code.
Check this example it is sounds similar to your query
http://jqueryui.com/tooltip/#custom-animation
timeout = setTimeout(function () {
$("#tooltip").hide('fast');//change these options
}, 500);
Are you looking for Tooltip timeout ??
Change the time delay in timeout function as per your requirement.
I have a javascript function that I use to animate the filling out of a form. Basically like a tutorial to show customers what and how to enter their information. I was wondering if anyone had any ideas on what I could use to pause my animations. For example a have a button that when clicked would pause the animation and when clicked again would continue the animation.
My animation is basically several setTimeout's inside of each other.
Example
setTimeout(function(){
$('#box1').val("1");
setTimeout(function(){
$('#box2').val("2");
setTimeout()....... and so on
},2000);
},200);
any ideas would be greatly appreciated thanks.
i m not sure but maybe you can use
$("#box1").stop(true).hide('fast');
OR
setTimeout(function(){ $("#box1").hide(); }, 3000);
use this:
myVar=setInterval(yourfunc(),2000);
for pause use:
cleartInterval(myVar);
you can check my func here: http://jsfiddle.net/YSfpm/
How can I possibly delay the disappearance of the menu by some miliseconds/seconds?
going ahead and editing this fadesettings: {overduration: 350, outduration: 2000}in the js only changes the animation speed. But THAT IS NOT what I want =).
Please check this JSFiddle to see the JS, CSS, and HTML.
Thanks for the help guys
P.S:- about the top:80px gap that you see, I intentionally put it there cuz that's the way I'm styling my site so I want the gap there.
You can user the setTimeout function to add a delay before you call a function.
In your case, if you want to delay the fadeout of the menu, instead of just doing :
$this.children("ul:eq(0)").fadeOut(jquerycssmenu.fadesettings.outduration);
You could do
setTimeout(function() { $this.children("ul:eq(0)").fadeOut(jquerycssmenu.fadesettings.outduration)
}, 2000);
to delay the call by 2 seconds.
Note that I cached the $(this) selector in your fiddle to still be able to access the variable.
http://jsfiddle.net/KB5Ve/
EDIT :
Added comments on the fiddle : http://jsfiddle.net/DBvq7/
I use simpletip jquery plugin and I want to make some changes in it. I want the tooltip to appear after some time (milliseconds) when hovering the link. Unfortunately I'm not familiar with jquery enough. Can anyone point out how this can be done?
http://craigsworks.com/projects/simpletip/
Thanks in advance
Simply use the hoverIntent plugin
It looks like you can define a custom effect for showing the tooltip.
In your configuration, define showEffect: 'custom', and showCustom property. It should look something like this:
showEffect: 'custom',
showCustom: function(tip, duration) {
tip.delay(550).fadeIn(duration);
}
In this case, the fadeIn will be delayed for 550 milliseconds. duration is the showTime specified in your configuration, or, if omitted 150 milliseconds.
you could use the onBeforeShow callback event in the simpletip plugin, and just use a delay in that so it delays before it returns and continues to show the tip.
I have the following code:
t = setTimeout(function () { blah(); }, 900000);
Which, basically, calls blah after 15 minutes of the page having loaded.
However, if at some point I show an alert() or a confirm(), then as soon as it is dismissed, blah() gets executed for some reason.
As far as I've seen, this only happens in Safari/Chrome. It doesn't happen in IE/Firefox.
Any ideas what's going on, or even better, how to solve this?
Thanks!
Daniel
You are not alone, this is the bug: code.google.com/p/chromium/issues/detail?id=43796
This problem has not been solved by the chromium team.
I found that, by introducing some delay between clearTimeout and the setTimeout, will solve the problem.
// mouse event
document.onmousemove = function(){
clearTimeout(timeout);
debug("Idle Timer reinitialized"); // apparently this function introduces some delay. it just works. You may want to include another timer here like for 2-3 seconds.
timeout = setTimeout(logoutNow, systemTimeout);
}
hope it helps.
Are you sure that is the cause, I ran this demo and can not replicate it.
"Timeout!" will appear after 10 seconds, click in the box before hand to test.
http://jsfiddle.net/PFgaJ/