Jquery, adding new function to the second click

2019-08-05 04:08发布

I am trying to add new effect after the first click. When submit is clicked for the first time it is working fine. How to make it function after the first click?

  if($('input#submit:not(.clicked)')){
                 $(this).addClass("clicked");
               $('.error').hide().fadeIn(700);
             }  else {
                 $('.error').fadeOut(10000).fadeIn(700);
             }             

2条回答
等我变得足够好
2楼-- · 2019-08-05 04:53
$('input#sumbit').click(function(){
  if( $(this).hasClass("clicked"))
  {
     $('.error').fadeOut(10000).fadeIn(700); // non-first click effect
  }
  else
  {
     $(this).addClass("clicked");
     $('.error').hide().fadeIn(700); //first click effect
  }
});
查看更多
男人必须洒脱
3楼-- · 2019-08-05 05:05
$('input#submit').bind('click',function(){
    //your function here
    ...


    //and your new click function is here
    $('input#submit').unbind('click').bind('click',function(){
        ...
    })
})
查看更多
登录 后发表回答