0

In JavaScript (preferably jQuery) how could I create a new element and set its values, but I want it in a specific place In the document.

My divs are structured like this :

/*
container
   item
      [item to be created inserted here]

*/

I know how to do this and insert it before the end body tag, but not like this.
I also say in jQuery, as most of my site is written in jQuery (only the js parts)

Thanks, Matthew.

Edited by Matthew N.: n/a

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Matthew N.
0
$("#item").html()

to replace the inner HTML of #item,

$("#item").before()

to add something before #item,

$("#item").after()

to add something after #item,

$("#item").append()

to add something to the HTML in #item

or just use JavaScript:

document.getElementById('item').innerHTML = "...";

Edited by Agarsia: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.