0

I have the following HTML:

<div class="control-group">
            <input value="" id="email" name="email" type="text" placeholder="E-mail"/> <span class="help-inline"></span>
          </div>

And the follow jQuery:

var input = $(this);

$.getJSON("/email", { email: data }, function(json){
                if(json.valid == true){
                    input.parent().addClass("success");
                }
            });

How can I add the class 'success' to the div control-group? Also, how can I add content to the help-inline span?

Thanks.

1 Answer 1

2

If your code is alright , to adding class to .control-group is right

and to adding content to .help-inline, you can use .next() like...

input.next(".help-inline").html("your text");

or...

input.next(".help-inline").html("your text").parent().addClass("success");

Full code :

var input = $(this);

$.getJSON("/email", { email: data }, function(json){
                if(json.valid == true){
                    input.parent().addClass("success");
                    input.next(".help-inline").html("your text");
                }
});
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.