2

is there a neat way to add html with jQuery instead of

$("#elm").html($("#elm").html() + "some text");

It'd be great to just do $("#elm").html(+= "some text") or something similar...

1 Answer 1

6
$('#elm').append('some text');

http://docs.jquery.com/Manipulation/append for more information on using append

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

2 Comments

So doing this would just append a text node?
if you do .append('<span>some text</span>') you'll get it in a span ;)

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.