How To Use Hover Function To Stop Script
Oct 9, 2011
I am working on an image changer. I found that if I do a fadeout/fadein on an element and then try to do another fadeout/fadein on the same element it does not work so I put my fadeout/fadein inside a function and do all my work in the callback portion along with a call to self to make the function keep running in a loop. I just need to know how to incorporate the hover function to make the script stop while hovered over a specific element (will be one of 6 image divs).
Here is the code
Code:
$(document).ready(function() {
var newImage = 'img/1.jpg'; //starts the process with the first image (same as the one in css background-image)
imgreplace(newImage);
});
var files = new Array('img/1.jpg', 'img/2.jpg', 'img/3.jpg');
function imgreplace(newImage){
$("#imgbox").fadeOut(500, function(){
$(this).css('background-image' , 'url(' + newImage + ')').fadeIn(500);
var currImage = newImage; .....
I need to get the randomness fixed because it is still returning the same image sometimes but other than that it works. I just need to be able to hault the function on hover and let it restart where it left off when I move the mouse away. In the unhover section I will be adding code to place an overlay image and href link but I don't think that will be a problem if I can get the start/stop working with hover. Actually I'm hoping to set some variable and use it in my getNewImage function so the other images continue to change but getting the entire script to stop so all the images stop changing will be OK.
View 1 Replies
ADVERTISEMENT
Jul 28, 2010
Here is my problem broken down:I have some animation inside a function like this:
function doAnimation() {
$('div.nav').animate({left: 15}, 200, 'swing')
$('div.nav').animate({left: 10}, 200, 'swing')
[code]....
View 5 Replies
View Related
Nov 29, 2009
Im playing around with some JQuery and have a small problem with my menu. I want the text to always be visible, be on hover and not on hover. Currently, the text is only visible when I hover the <li> item. Check it out at http://cooper.zxq.netBelow is my code using to produce the menu.
<html>
<head>
<script src="jquery-1.3.1.min.js" type="text/javascript" ></script>
[code]....
View 3 Replies
View Related
Jul 5, 2011
I'm using jQuery to create a hover effect when a user hovers over a div. This is fine, as usual all browsers except IE do what I need of them. Inside my divs I have some text and to get the whole div area to be the link I have simply placed an anchor (last in the div in html) and abs pos'd it, given it a z-index and displayed it as block so that it is now the whole div as a link. But because of the text, IE is giving priority to the text so when I hover the div, if I hover into the text area it is taking the hovered stated off of the div. I need to stop IE bringing the text to the front. This happens in all versions of IE inc 9
View 6 Replies
View Related
Jun 30, 2009
how can i make the text stop sliding to the right on hover?
View 2 Replies
View Related
Nov 18, 2010
I have a simple navigation system, and I am using hover, to show/hide details, but if I hover back and forth too fast between the elements, the animation queues up and keeps executing even when I am not hovering over them.
[Code]...
I can use stop() on animate to prevent queuing, but doing it like in the code above, stops the animation from even happening. Please suggest a solution.
View 3 Replies
View Related
Jul 23, 2011
I need to know how stop a action hover and just the last action happen
View 2 Replies
View Related
Nov 9, 2011
How do I stop the displaymessage function when i ==1 code...
View 6 Replies
View Related
Jun 22, 2006
i have a function, i want it to keep doing the function while the mouse is over a button and then stop when its off.....to repeat i can just call the function again at the end of the function like this:
onMouseOver="doFunction()"
doFunction() {
//do something
doFunction();
}
but how can i make a function stop to it onmouseout?
View 4 Replies
View Related
Oct 21, 2011
How do you stop a countdown function?
View 6 Replies
View Related
Mar 20, 2009
I used this expandable menu bar from this site(example on the site)
anyways, i want an alert window with the height of the menu bar.[code]...
View 8 Replies
View Related
Oct 6, 2010
Is there a function to tell jquery to only do something on the first instance that matches then to stop. For example I add a class to a LI to an UL with the below but it adds the LI to all ULs under it.
$("div#container ul").prepend("<li>Home</li>");
Original code:
<ul><li>
<ul><li>item</li>
</ul></li>
</ul>
Code needed:
<ul>
<li>Home</li>
<li><ul>
<li>item</li>
</ul></li></ul>
Currently Output code:
<ul>
<li>Home</li>
<li><ul>
<li>Home</li>
<li>item</li>
</ul></li></ul>
View 3 Replies
View Related
Nov 15, 2011
I have an auto running function which slides and changes content every 3 seconds.
But I also have another jquery effect which when you click, it also changes the effect, but at the moment I can't have both running at the same time as weird behaviour happens (when clicking, it changes then because 3 seconds have passed it changes again anyway).
We want a way where the user clicks to change, and the auto running function ceases until next reload of the page. code...
View 9 Replies
View Related
Apr 28, 2010
JavaScript
window.addEvent('domready',function(){
//SAMPLE 8
var handles8_more = $$('#handles8_more span');
var nS8 = new noobSlide({
[Code]....
All I need to do is when they hover ocer the div statement stop the program from looping. and then when they stop hovering over it let it start looping again.
View 1 Replies
View Related
Mar 30, 2009
Is there a function in javascript the same as PHP's exit(). I have:
<script>
****EXIT OR EQUIVILENT IN JAVASCRIPT*****
</script>
<a id="java" style="color:#FFFFFF; ">Enable javascript to view my website</a>
This tells me if javascript is on or off.
View 1 Replies
View Related
May 11, 2010
I have got two div's for javascript, dyn1 and dyn2. Dyn1 on mouse over sets a interval and on mouse out clears the interval.
When the page loads it calls a function called 'first' and this displays a table in dyn1.
Then the user can click a link and this calls another function 'second' which deleted the table in dyn1 and creates a table in dyn2 and is suposed to clear the setInterval.
The problem is after a second of clearing dyn1 and creating the table in dyn2 the setinterval is still running and deletes dyn2 and re creates the table in dyn1.
Is it possible to stop a interval when the user clicks a link? At the moment the second function is calling the stoptimer() function to try and stop it.
View 8 Replies
View Related
Aug 25, 2010
I've this script that make change a class every 3 seconds. How do I stop the loop, so it will stop on the second class?
$(function() {
var $target = $("#wrap");
var classes = ['hide', 'show'];
var current = 0;
[Code].....
View 2 Replies
View Related
Apr 6, 2010
This script works to stop a right click unless the alert() is taken out.
1. Why is this ?
2. How do you get this to work without the alert() ?
function f(e){
if (event.button==2){
alert('Please no right click.');
return false;
}}
document.onmousedown=f
View 1 Replies
View Related
Aug 31, 2011
I'm having some difficulty preventing a function from executing. Here's a scenario: I have a drop down list that has a sub menu. When you "mouseover" the menu heading, the sub menu expand and when you "mouseout" the menu heading, the submenu collapse. I also add "mouseover" and "mouseout" listeners to the sub menu. My trouble is how do I prevent the drop down list from collapsing so that I can get to the sub menu. And only collapse when there is a "mouseout" on both the menu heading and the sub menu? How do I prevent a function from executing, from inside another function?
View 1 Replies
View Related
Dec 6, 2009
I'm using jQuery and i have an animation effect which is executed via two methods:-
method 1: clicking on a nav link.
method 2: manually scrolling past a specified point.
Now, since method 1 will make the page scroll to the relevant anchor, by it's nature, it will trigger method 2.
What i need is a way to prevent method 2 from executing if method 1 is in operation.
View 5 Replies
View Related
Apr 5, 2010
i m working on a file i created a function which i call upon when body tag load but it loads so many window. coz its going in a loop. how can i stop it? here is the code
Code HTML4Strict:
<html>
<head>
[code]......
View 2 Replies
View Related
Aug 1, 2011
I'm using the color animatepluginto animate some colors.I'm animating the width on hover and using .stop() before each animation.when i click my paragraph it animates the color of the div back and forth with a callback function to reset the background color in case .stop() freezes the color. But the callback function is not called.try it here:[URL]Now I want to always call the callback function.
View 3 Replies
View Related
Jul 1, 2009
I have a hover function that also has the "rollout" function attached to itHowever, I also call a different function when the user clicks. This function when clicked, changes the class name, however, the hover function, is waiting for my "rollout" and does stuff that I don't want after the click has happenedOk, that was confusing.Let me show you with code:Hover Function:
(basically turns on/off an image)
$(document).ready(function() {
$('.hotelCat').hover(function(){
[code]....
View 1 Replies
View Related
Apr 20, 2011
my jquery was intially was
$(document).ready(function () {
$('ul.nav li').hover(
function () {
[code]....
View 4 Replies
View Related
Oct 9, 2009
I'm trying to make a dropdown navigation menu with animated submenus.
Code JavaScript:
$(document).ready(function() {
$("#subnav .navigation > li").hover(
[code]....
View 1 Replies
View Related
Jul 20, 2005
how to stop the document.write opening a new window when called in a function, what I want to do is really simple but is defeating at every turn.I have a line of text that is a link on an html page,when clicked i want the the function called to print a name, imediatly after the
calling link (on the same page).
View 12 Replies
View Related