I need the variable ‘gv’ to have the value of a button, i did this with this.value and it worked as alerts give the right values. but once i gave that variable to the speed parameter of an animation, it didn’t work.
i tried giving the variable right at the animation, but that didn’t work either. i also tried to give the animation random value’s to see if it was effected, and it was. but the variable doesn’t do anything at all.
$(document).ready(function() {
$("button").click(function() {
var GV = this.value;
$("#ball").animate({
bottom: "0px"
}, GV);
})
});
i expect the animation to pull the div to the bottom at the speed of 18999 milliseconds, but it pulls at 800 milliseconds
Seemi izaabel
this.value
is a string. According to JQuery Docs the strings allowed foranimate()
method parameters are ‘fast’ or ‘slow’. Any other string will be disregarded and the default speed will be used. UseparseInt($(this).val())
to get the integer value of the button element: