Reputation: 39
I want to execute $(".rope").click() function automatically after page has loaded completely.
<script type="text/javascript">
$(document).ready(function() {
$curtainopen = false;
$(".rope").click(function(){
$(this).blur();
if ($curtainopen == false){
$(this).stop().animate({top: '0px' }, {queue:false, duration:350, easing:'easeOutBounce'});
$(".leftcurtain").stop().animate({width:'60px'}, 4500 );
$(".rightcurtain").stop().animate({width:'60px'},4500 );
$curtainopen = true;
}else{
$(this).stop().animate({top: '-40px' }, {queue:false, duration:350, easing:'easeOutBounce'});
$(".leftcurtain").stop().animate({width:'50%'}, 4500 );
$(".rightcurtain").stop().animate({width:'51%'},4500 );
$curtainopen = false;
}
return false;
});
});
</script>
Please Help.
Upvotes: 0
Views: 2210
Reputation: 160843
I'd like to chain it behind:
$(".rope").click(function(){
$(this).blur();
if ($curtainopen == false){
$(this).stop().animate({top: '0px' }, {queue:false, duration:350, easing:'easeOutBounce'});
$(".leftcurtain").stop().animate({width:'60px'}, 4500 );
$(".rightcurtain").stop().animate({width:'60px'},4500 );
$curtainopen = true;
}else{
$(this).stop().animate({top: '-40px' }, {queue:false, duration:350, easing:'easeOutBounce'});
$(".leftcurtain").stop().animate({width:'50%'}, 4500 );
$(".rightcurtain").stop().animate({width:'51%'},4500 );
$curtainopen = false;
}
return false;
}).click();
Upvotes: 0
Reputation: 82241
use .click()
or .trigger('click')
in dom ready with selector:
$(".rope").click();
//or
$(".rope").trigger('click');
Upvotes: 2
Reputation: 5326
You can write this after your listener definition:
$(".rope").click()
or
$(".rope").trigger( 'click' )
Upvotes: 1