J.Aurélien J.Aurélien - 1 year ago 92
jQuery Question

If margin left == percent

I want my div to go left 5 times and after that coming back.
To do that I have that script :

Javascrpit :

$(document).ready(function() {
if(document.getElementById('twitter').style.marginLeft == "-278%")

marginLeft: '+=278%',

}, 5000);

marginLeft: '-=55.6%',

}, 5000);

I have a working script with px using :


but I need percent to be responsive, can someone help me please ?


The animation is working, just the condition for the if isn't working.

Answer Source

Use position: absolute and left attribute instead of margin-left

<div id='twitter'>

 position: absolute;
 left: -50%;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download