JQuery :: $.animate With One Value Depending On The Other
Apr 30, 2010
i want to make an animation where one value depends on the other.
Let's say i want to animate both the 'top' and 'marginTop' properties, where i want the marginTop property to use the current value of the 'top' property.
I could do something like this:
$("#foo").animate({
top : "100px",
marginTop : ($("#foo").css('top') * 2) + 'px'
});
But that doesn't work, i guess because the css('top') method only gets called after the animation has finished.
Is there a trick to get the value of 'top' in the 'marginTop' property?
View 2 Replies
ADVERTISEMENT
May 16, 2011
I cant get the scrollbar to animate to 500px, onload.
Here is a link to my page...[url]
<script type="text/javascript">
View 5 Replies
View Related
Jun 2, 2010
I have a toggle animation which puts the area I want to show to the user in view, ones that animation has played I want to animate several other objects on the page. I have the code to animate one object by using the callback function in animate. But is it possible to animate several objects in the callback function?. this is the code I have so far
$(document).ready(function(){
$(".navigaat").toggle(function(){
$(".mover").animate({left: '0px' }, 'slow',"", function() { $(".blok").animate( { fontSize:"160px" } , 1000 )});
[code]....
View 4 Replies
View Related
Nov 19, 2011
I use the wonderful .animate() method to create a "parallax website". It's still in developpement, but you can see the result : www.ohnewgarden.fr My problem : When you are at the very right, the animate effect reset my left property before animating. Which is weird is that this "reset" is applied only to two layers, without any sense. I'm going crazy !
So if someone could help me, it will be very nice ! It's probably my code which is wrong, but I can't see the mistake.
[Code]...
I said for my defense, I have tried to remove .stop(), tried to change parameters of .stop(), tried to reset (like there) the left property with a .css() method, and I have also tried to animate with "+=" (like there), but nothing works. If you follow to the link I gave, you could see very easily by clicking on "Contact" and after animation by clicking on "Accueil".
View 2 Replies
View Related
Dec 27, 2011
I have a div that has a negative top margin and a negative right margin. The right margin is because I want to have the div slide onto the page from the right. The top margin is because without it my page height is the height of the visible elements plus the height of the off-screen div.On a button click, I move the div down and then animate it onto the screen from the right. On button click again, I animate the div to the right, off the screen, and then move it up. I also toggle its width & padding so it will appear to grow/shrink as it moves on/off screen. At least that's what I am trying to do. The animation onto the screen looks good, but going off the screen, it appears to happen intantaneously, instead of animatedDoes anyone know how I can fix this?
$(".addPanels").live("click", function(){//now and in the future, show the add panels menu
var thisAddPanelsMenu = $(this).parent().prev(".addPanelsMenu");//get the addPanelsMenu
if(thisAddPanelsMenu.length) {//if the addPanelsMenu exists
[code]....
View 2 Replies
View Related
May 27, 2011
$("#ltr").live("mouseover", function() {
//swap class names
$("div#container").removeClass("rtl").addClass("ltr");
});
I run this function to swap class names when there is a mouseover event on an image with the ID "ltr". How would I run this same function but to occur when, for example, a variable "distance" was equal to 0? Basically, if distance = 0 then swap class names
View 2 Replies
View Related
Jan 10, 2010
I want to add a button, beside the "Add" and "Remove" button which pick random of users depending on a given value, lets say that the value is 2, then it would pick 2 users randomly and move them to box 2.
Code JavaScript:
$().ready(function() {
$('#add').click(function() {
return !$('#box1 option:selected').remove().appendTo('#box2');
[code]...
View 24 Replies
View Related
Oct 20, 2010
I'm fairly new to jquery and slowly picking it up as I go. Here is a problem I though would be simple-ish but I am stuck. I think I have most of what I need, I just need the correct way of writing 1 part of it.
[Code]...
View 4 Replies
View Related
May 27, 2009
I have the following Javascript code and I can't seem to get it to work properly...
function DeleteSelectedBookmarks() {
bookmarksToBeDeleted = array();
if (document.deletebookmark.elements.length == 1) {
if (document.deletebookmark.deletebookmark.checked) array_push(bookmarksToBeDeleted, document.deletebookmark.deletebookmark.value);
} else {
checkboxes = document.deletebookmark.deletebookmark;
for (i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) array_push(bookmarksToBeDeleted, checkboxes[i].value);
}} if (count(bookmarksToBeDeleted) == 0) {
alert("You haven't selected any bookmarks to delete.");
return;
}
$.get("bookmarks.php", {delete: serialize(bookmarksToBeDeleted)},
function (result, bookmarksToBeDeleted) {
if (result == "done") {
if (count(bookmarksToBeDeleted) == 1) alert("Bookmark Deleted.");
else alert("Bookmarks Deleted.");
} RefreshBookmarks();
});}
What it is supposes to do is gather the amount of bookmarks that need to be deleted and then send the command to the server to do so. The server then gives a message back (if it is successfully the result is "done") and depending upon how many bookmarks it deleted it gives a different result, ie. singular vs. plural. How do I do this?
View 1 Replies
View Related
Mar 25, 2011
I have a single page which uses tabs to segment the content. Alongside the tabs themselves is a button for 'Help'. I'd like this button to open a different DIV depending upon the tab that is currently being used.For example, if I am on a tab for 'Ben', if I click the 'Help' button I want the 'helpBen' DIV to slideToggle.If I am on a tab for 'Paul', when I click the 'Help' button I want it to open the 'helpPaul' div.
Some extra needs:
1. switching to a different tab should close the currently open help div (e.g. helpBen or helpPaul)
2. There should only be one help div (e.g. helpBen or helpPaul) open at any one time.
I partly solved this with the following code but with erratic results and I'd like to know what I'm dong so wrong!Here is the HTML for the help button:
<a class="helpTrigger" href="#">Help</a>
The help DIV's are like this:
<div class="helpBen">help relevant to Ben section</div>
<div class="helpPaul">help relevant to Paul section</div>
The CSS for .help is display: none; by default so none are shown from the outset.
And here is the jQuery
$(".helpTrigger").click(function(){
if (location.hash == '#Ben') {[code].....
In the words of Dr Evil, "throw me a frikkin' bone here..."
View 6 Replies
View Related
Oct 16, 2010
If I have an 'dynamic' Div that sometimes contains the word Red or sometimes contains the word Green, i would like to replace (or something) the ID to something else.If the word inside the div is Green I need to use a green background, but if the word is red in the div, i need to have it in a red background.
<div id="x">Green</div>
<style>
#y {
background-color:Red;
[code]....
View 2 Replies
View Related
Aug 12, 2011
I was wondering if there is a way to use Jquery to reduce the amount of images I use on my company website as well as resize them depending on the page they're displayed on. It's just that I feel that's it's very tedious creating 5 or 6 formats for each campaign each with it's own dimensions depending on the page and unfortunately my company doesn't want to implement a Backoffice fed site, which means I have to do it all manually.
View 3 Replies
View Related
Sep 7, 2010
I've been going round in circles on this big time, getting very annoyed, and can't seem to find an answer anywhere. This little bit of jQuery collapses our menu, so that when we roll over, the sub menus float out:
<script type="text/javascript">
function initMenu() {
$('#SideCategoryList ul ul').hide();
$('#SideCategoryList li a').hover(
function() {
$(this).next().slideToggle('slow');
}
);
[Code]....
View 8 Replies
View Related
Apr 22, 2009
I have a list that looks like this:
<ul id="thisList">
<li class="this0">content</li>
<li class="this1">content</li>
<li class="this1">content</li>
[Code].....
View 4 Replies
View Related
Oct 14, 2010
How to change style on a series of divs (with similar structure but different content) *only if* all the children are visible (that's using visibility, not display).
Sample div:
<div class="h">
<p class="a1">text</p>
<p class="b2">more text></p>
<p class="b3">text text</p>
<p class="a4">text...</p>
<p class="link_display_none_visibility_visible">div name</p></div>
I think it needs to use contents(), but not sure about handling node numbers.
View 5 Replies
View Related
Jun 18, 2010
First, my url looks like this [url]...
I would like, depending on the value of the anchor called, to add a class to the box related.[code]...
View 14 Replies
View Related
Jun 28, 2009
What I'm trying to do is create three rules depending on the path of a page. If the path contains 'best-sellers', I want jQuery to set the class of the page to 'pm-best-sellers'. I can do this, and it works, but when I add the rules for 'express-gifts' and 'eco-friendly' it breaks.
Here's what I've got:
View 8 Replies
View Related
Aug 4, 2010
how one can show and hide a div element using a pulldown menu. i need the different selections in the pulldown menu to show hidden DIV elements on the page. this will be used in a system where i only have access to the template, so the only approach i can use is jquery. how to change it for the specific selectors i need.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
[Code].....
View 2 Replies
View Related
Dec 7, 2010
I have 2 divs, 1 is just off the screen to the left, and the other visible. the divs contain unordered lists. Now when i click on one of the 'li' list items i would like to slide div 1 to the left off screen and bring div 2 to the right on screen. so this is what i have done so far:
<script>
var swap =0;
$("(#cat)li:first").click(function(){
if(swap==0){
$("#cat").animate({"left": "-=150px"}, "slow");
[Code]..
View 4 Replies
View Related
Jul 31, 2010
have this code: $('#showLayers').click(function()
[Code]...
If I add a alert inside the click(), and after the animate, that one is never triggered as well.
View 2 Replies
View Related
May 4, 2010
I have a big problem, here is the sample of code:
<ul>
<li>
<a href="#"> <img src="#" /> </a>
<div class="info">
[Code]....
So, normaly the div.info element is with css: display:none; And there is displaying only "a" element. But i have a little code of jquery who makes the div.info element showup when the mouse over on the "li" element. And code is working as i expecting, but not in the IE.
var pic = $('ul li');
pic.hover(function(){
$('div.info', this).stop().animate({opacity:'0'}, 600, function(){
[Code]...
View 2 Replies
View Related
Jan 31, 2010
This sure has me puzzled since it's usually the other way around. The script below, straight from a book, works in IE, but not in FF, Chrome, or Safari. Can anyone tell me what I'm not doing that would work in the Good browsers
[Code]...
View 3 Replies
View Related
Jan 27, 2010
here is my [URL].. Basically when mouseover I animate the opacity. Works well in Firefox but in IE 8, the shadow appear on the text. Is there anything I miss out or is there any problem with my PNG file?
View 4 Replies
View Related
Nov 2, 2010
I cannot get the dimensions of my swf to animate for whatever reason. This works:
function resizeSwf(contentHeight){
document.getElementById('swfplayer').height = contentHeight + 20;
}
But this does not:
function resizeSwf(contentHeight){
$("#swfplayer").animate({
height:contentHeight + 20
},400);
}
I am using jquery-1.4.3.min.js and I have verified it is at the correct path.
View 2 Replies
View Related
Aug 5, 2009
[url]
If you click the link in FF you will see that when you press "PLAY" the arrow image animates from the top like it is supposed to... but does not show up in IE.
This could be a jQuery or CSS issue...
JQ:
HTML:
CSS:
View 1 Replies
View Related
May 2, 2009
Is it possible to use animate() using variables? My code is sound but when I try to replace the CSS value with a variable, it suddenly won't work in IE7.
//First, here's the code that works in all 3 browsers: FF, Chrome, and IE7
$('#btn').click(function(){
//no problem here
[code]....
View 1 Replies
View Related