Friday, 23 August 2013

using functions with jquery

using functions with jquery

So im really bad at js....anytime I need to write a function all goes to
shit. I think functions need to be written a certain way depending on what
they are supposed to do so I never get them working. Anyway I know Jquery
pretty good, but could someone point me in the right direction for this
fiddle...I need the div to animate on hover, but only when the class has
been added by the click function.
http://jsfiddle.net/BKFN3/2/
$(".move").click( function(event){
event.preventDefault();
if ($(this).hasClass("isDown") ) {
$(this).stop().animate({opacity:"0.5"}, 270);
$(this).removeClass("isDown");
//can put hover in here????
} else {
$(this).stop().animate({opacity:"1"}, 300);
$(this).addClass("isDown");
}
return false;
});
if ($(".move").hasClass("isDown")){
$(".fuckerMOVE").hover(
function() {
$(this).stop().animate({top:"10px"},215);
},
function() {
$(this).stop().animate({top:"0px"},230);
});
}
sorry for the bad code

No comments:

Post a Comment