2

I have the following HTML

<input type="submit" name="cm-ajax-submit" value="Register">

I need to append a div tag so it'll have this format

<input type="submit" name="cm-ajax-submit" value="Register"><div id="cmprivacy"></div>

Is there a way to use jQuery append or another function to find the input with the name cm-ajax-submit and append that div?

Thanks

3 Answers 3

13

Create the element and move it using .after,

$('input[name=cm-ajax-submit]').after('<div id="cmprivacy"></div>');
Sign up to request clarification or add additional context in comments.

Comments

6

Use the .after function, not .append.

html:

<input id="button" type="submit" name="cm-ajax-submit" value="Register">​

jQuery:

$('#button').click(function() {
    $(this).after('<div id="cmprivacy">Hey</div>');
});​

http://jsfiddle.net/sfsWC/

Comments

2

Try this.. Use .after() method

$('input[name="cm-ajax-submit"]').after('<div id="cmprivacy"></div>')

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.