Reputation: 786
I am trying to write a piece of code that animates a div when a URL is visited. Here's my code:
if(document.URL.indexOf("index.php") >= 0){
$('#popout-left-menu-container')
.animate(
{
'right':'-3px'
},500
);
};
I have tried this but it doesn't animate?
I have the below piece of text which does work when the #open-menu-button id is clicked.
Any ideas? Many thanks.
$(document).ready(
function(){
$('#open-menu-button').click(
function(){
$('#popout-left-menu-container')
.animate(
{
'right':'-3px'
},500
);
});
$('#popoutmenuclose').click(
function(){
$('#popout-left-menu-container')
.animate(
{
'right':'-1500px'
},500
);
});
});
Upvotes: 0
Views: 76
Reputation: 6202
Since the questioner asked to see the implementation discussed in the comments, here it is:
$(document).ready(
function(){
if(document.URL.indexOf("index.php") >= 0){
$('#popout-left-menu-container')
.animate(
{
'right':'-3px'
},500
);
};
});
Note that the code is similar but will only fire on document.ready()
.
Upvotes: 1