0

I have a submit button which is disabled until a user chooses from a select list.

I want to remove the disabled attribute and also add a class so the button becomes the standard button class I use throughout the site, on change of the select list.

I am trying the following:

$(document).ready(
function(){
    $('#category').change(
        function(){
            if ($(this).val()) {
                $('input:submit').attr('disabled',false);
                $('#btn_show').addClass.attr('button green');

            }
        });

});

#category is the drop-down id and #btn_show is the button id

The disabled is removed ok but the class not added. Is my logic correct?

Also, is it also possible to change the value of the submit button when this change happens too?

2
  • can you post a fiddle Commented Sep 23, 2012 at 17:22
  • Also, addclass should be something like $('#id').addClass('class to be added') Commented Sep 23, 2012 at 17:24

2 Answers 2

5

You should use $('#btn_show').addClass('green');

Please read the manual: http://api.jquery.com/addClass/

Sign up to request clarification or add additional context in comments.

1 Comment

then the classses should be separated by a space
4

this can be done by jquery addClass('class_name') api

try this

$('#btn_show').addClass('button green');

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.