22509

Jquery, adding new function to the second click

Question:

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); }

Answer1:

$('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 } });

Answer2:

$('input#submit').bind('click',function(){ //your function here ... //and your new click function is here $('input#submit').unbind('click').bind('click',function(){ ... }) })

Recommend

  • CKeditor stripping font tags instead of converting to span
  • change color of jstree node
  • Ionic Slide Up Slide Down Animation for only one view in sidebar
  • LESS CSS how to modify parent property in mixin
  • Prevent Tomcat from caching request during starup
  • Subclassing QGraphicsItem prevents me from being able to use itemAt() on a QGraphicsScene/View
  • Selenium to click on a javascript button corresponding to a text
  • Button click event not firing in jQuery
  • Detect when Facebook like button is clicked
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • JSON response opens as a file, but I can't access it with JavaScript
  • How to use an array of arrays with array_map(…) in PHP?
  • FFmpeg Conversion Error
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • req.body is undefined - nodejs
  • Sony Xperia Z Tablet not found by adb
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Does CUDA 5 support STL or THRUST inside the device code?
  • what is the difference between the asp.net mvc application and asp.net web application
  • jquery mobile loadPage not working
  • How can I estimate amount of memory left with calling System.gc()?
  • Data Validation Drop Down Box Arrow Disappearing
  • Matrix multiplication with MKL
  • Hits per day in Google Big Query
  • How do you join a server to an Active Directory (domain)?
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Android Google Maps API OnLocationChanged only called once
  • File not found error Google Drive API
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Binding checkboxes to object values in AngularJs
  • UserPrincipal.Current returns apppool on IIS
  • Converting MP3 duration time
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?