I’m still very new to JQuery. I don’t seem to be able to get the following code to work.
$('.announcement_panel_button').click(function(e){
$('#site_logo').animate(function(){
$(this).css('margin-top', '5px')
}, 5000);
e.preventDefault();
});
Or if there are some other way to rewrite this.
Your
animatefunction’s syntax is not right, try it likeWorking Fiddle
Check the syntax on $.animate
As @Tats_innit explained in his answer,
e.preventDefault();might not be necessary if it’s a simple button. It’s needed when you want to prevent a default action like,clicking <a> tags takes you to new urlorform submit.