0

I have CSS for a submit button (shortened for ease of reading):

input[type="submit"] 
{
background-color:#3bb3e0;
padding:10px;
position:relative;
font-family: Arial, sans-serif;
font-size:12px;
text-decoration:none;
color:#fff;
border: solid 1px #186f8f;
border-radius: 5px;
cursor:pointer;
}

When a user if filling out a form, whilst error checking using ajax I want to disable the submit button and change its color if the user enters something wrong, so I use the following jquery:

if(response == 0)
{
$("#button").addClass("buttonDisable");
$('#cross').fadeIn();
$('#button').prop('disabled', true);
}

The button disables ok but the CSS has no effect as the inspector shows it added after the initial css therefore it is crossed out:

input[type="submit"].buttonDisable { background-color:#ccc; border:1px solid #666; }

QUESTION: How can I make the class have an effect on the button?

4
  • 9
    This would be such a hilarious question title on fashion.stackexchange.com if it existed :) Commented May 12, 2013 at 7:51
  • Seems working to me.. jsfiddle.net/23UAs Commented May 12, 2013 at 7:57
  • @PalashMondal Definitely not working when used as above, reading the result of an ajax call - The inspector shows the class is added but it doesn't change it's style Commented May 12, 2013 at 8:02
  • The other way round it would be even funnier: Changing style doesn't add class Commented May 12, 2013 at 8:08

1 Answer 1

2

Try this:-

input[type="submit"][disabled] { background-color:#ccc; border:1px solid #666; }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.