00 Votes

jQuery: Add Content to DIV

Question by Guest | 2015-07-19 at 14:40

In my HTML code, I have a simple DIV box, in which some content is arranged.

Now, I would like to add some new content at the bottom of the DIV dynamically - the present content of the DIV should remain untouched.

In other words, I am searching for a jQuery function, making it possible to add something to a DIV. Does someone know a method for this?

ReplyPositiveNegative
0Best Answer0 Votes

You are searching for the function .append() available in jQuery. Here is a small example of how to use this function:

$("#mydiv").append("<p>New Content</p>");

Here, we are adding the new content "<p>New Content</p>" to the bottom of the DIV with the ID "mydiv". Of course, you can also pass a variable containing the new content to the function.
2015-07-19 at 15:26

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.