Changing images in jQuery -
i trying make image change when clicking li element, in sense move navigator bar , move down image background! thing code image changes before moves (so image changes early), , i'm not sure how fix it...
here jquery
var click = false; $("#1").mouseenter(function(){ $("#1 span.indicator").css("color", "#ffa1d4"); }); $("#1").on("click",function(){ if (click = false){ var click = true; } else { var click = false; $("div.container").animate({height: '0%'}); $("div.container").animate({width: '500px'}); } $("div.container").css("background-color", "#faf4fc"); $("div.container").css("background-image","url(images/1.jpg)"); $("div.container").animate({height: '100%'}); $("div.container").animate({width: '100%'}); document.getelementbyid('title').innerhtml = "1"; }); $("#1").mouseleave(function(){ $("#1 span.indicator").css("color", "#a187be"); }); $("#2").mouseenter(function(){ $("#2 span.indicator").css("color", "#ffa1d4"); }); $("#2").on("click",function(){ if (click = false){ var click = true; } else { var click = false; $("div.container").animate({height: '0%'}); $("div.container").animate({width: '500px'}); } $("div.container").css("background-color", "#faf4fc"); $("div.container").css("background-image","url(images/2.jpg)"); $("div.container").animate({height: '100%'}); $("div.container").animate({width: '100%'}); document.getelementbyid('title').innerhtml = "2"; }); $("#2").mouseleave(function(){ $("#2 span.indicator").css("color", "#a187be"); }); i hope bit clear ;;
animate has callback function think need use
here demo https://jsfiddle.net/6fhzqr40/
$('#btn').click(function(){ $("div").animate({height: '0', width: '0'},2000 , function(){ andimatetwo(); }); }); function andimatetwo(){ $("div").css('background-color', 'green'); $("div").animate({height: '500', width: '500'},2000 , function(){ }); }
Comments
Post a Comment