JQuery add/remove class?
JQuery add/remove class?
So I have been creating a simple coming soon page for a site. One of the things I want to be possible id that the form button changes class (colour and background image essentially). These scripts that it uses being process.php do work and I have validated that with the end collection of the emails once they have been put correctly into the form. I can say that all of the JQuery works up until the point where the user errors the form first and then gets a successful entering of the email. Heres my code and also a live version of the site. Any help would be greatly appreciated.
- $(document).ready(function() {
- $('#formContainer').submit(function() {
- var formData = $(this).serialize();
- $.post('process.php', formData, processData);
- function processData(data) {
- if (data=='1') {
- if ($('.button').hasClass('buttonFail')) {
- $('.button').removeClass('buttonFail').addClass('buttonSuccess').hide().fadeIn();
- }
- $('.form').append('<p class="alert">your email is in, we will let you know when we go live!</p>');
- $('.button').removeClass('button').addClass('buttonSuccess').hide().fadeIn();
-
- } else if (data=='2') {
- $('.button').removeClass('button').addClass('buttonFail').hide().fadeIn();
- } else if (data=='3') {
- $('.button').removeClass('button').addClass('buttonFail').hide().fadeIn();
- }
- }
- return false;
- });
- });