$(document).ready(function(){ $('.run').click(function(){ var $mgTop = $('.itmFirst').css('margin-top'); if($mgTop<'100px'){ $('.itmFirst').animate({marginTop:'+=30px'},1000,function(){}); }; }); |
1 answer
Work example http://jsfiddle.net/szpayf30/
$('.run').click(function(){ var mgTop = $('.itmFirst').css('margin-top').replace("px", ""); if(mgTop<100){ $('.itmFirst').animate({marginTop:'+=30px'},1000,function(){}); }; }); From the property string, remove the px substring so that only a number is left in the string. And further in the condition to compare with the number, and not with the string.
- thanks, now it works :) - Alexander
|
$mgTop<'100px'replace with$mgTop<100- VismanmarginTop:'+=30px'maybe not everything is right with the summation of the line. - Visman Sep.marginTop:'+=30px'is essentially all right. - Alexander