I am trying to create a unique movement for my div - it should move left five times and then come back. To achieve this, I have the following script:
Javascrpit :
$(document).ready(function() {
if(document.getElementById('twitter').style.marginLeft == "-278%")
{
(function($){
setInterval(function(){
$('#twitter').animate({
marginLeft: '+=278%',
},3000);
}, 5000);
})(jQuery);
}else{
(function($){
setInterval(function(){
$('#twitter').animate({
marginLeft: '-=55.6%',
},2000);
}, 5000);
})(jQuery);
}
});
While I currently have a functioning script using pixels with the condition:
if($('#twitter').css("marginLeft")==('-5300px'))
I need to make it more responsive by using percentages instead. Can anyone help me with this modification?
EDIT :
The animation itself is working fine, but there seems to be an issue with the condition in the if statement.