mohsin mohsin - 3 months ago 10
CSS Question

div animation not repeating on click in jquery

I am trying to animate div from outside the window to inside every time I click on link but it works only one time not again, please help me where I am wrong.

<li>
<a id='ajaxLoad1' onclick='ajaxFunc(event, this);' href="url1">1st content</a>
</li>
<li>
<a id='ajaxLoad2' onclick='ajaxFunc(event, this);' href="url2">2nd content</a>
</li>

<div id='contentDiv' style="background: #98bf21; height: 200px; width: 800px; position: absolute;"></div>


function ajaxFunc(param, thisParam) {
param.preventDefault();

var href = $(thisParam).attr('href');
var position = '100px';

$('#contentDiv').css('margin-left','-100%');
$("#contentDiv").animate({right: position});

$('#contentDiv').load(href);
}

Answer
$('#contentDiv').css({
  'right': 'initial',
  'margin-left': '-100%'
 });