我有以下 javascript。例如console.log('test')
加载 javascript 时的触发器。我希望它在我单击带有类登录的按钮时触发。我究竟做错了什么?
$(document).ready(function() {
switchImage(5000, '#top .images');
switchImage(5000, '#top .feature-text');
$('.login input').focus(function(){
$('.login .hidden').removeClass("hidden");
$('.login [type=text]').removeClass("span2").addClass("span3");
});
$('.loginbutton').click(login());
});
function login(){
event.preventDefault();
console.log('test')
}
function switchImage(wait, element){
//Fades out first element and put's it in the bottom of the stack
$(element+'>*:first-child').delay(wait).fadeOut('slow', function() {
//fade in imag2
$(element+'>*:nth-child(2)').fadeIn('slow');
$(element+'>*:first-child').appendTo(element);
switchImage(wait, element);
});
}