Javascript append html to body
I have many Show What else can I use?
kenorb 144k76 gold badges655 silver badges710 bronze badges
asked Nov 21, 2012 at 14:05
1 You can use
or
Amberlamps 37k5 gold badges39 silver badges53 bronze badges answered Nov 21, 2012 at 14:07
Sajjan SarkarSajjan Sarkar 3,6924 gold badges38 silver badges48 bronze badges 3
I Just came across to a similar to this question solution with included some performance statistics. It seems that example below is faster:
InnerHTML vs jQuery 1 vs appendChild vs innerAdjecentHTML. Reference: 1) Performance stats 2) API - insertAdjacentHTML I hope this will help. answered Jul 22, 2018 at 19:33
speksyspeksy 6208 silver badges12 bronze badges 2 I think if you want to add content directly to the body, the best way is:
To replace it, use:
answered Jan 16, 2015 at 10:30
WebbingWebbing 2632 silver badges2 bronze badges 3 Try the following syntax:
answered Aug 3, 2017 at 11:28
kenorbkenorb 144k76 gold badges655 silver badges710 bronze badges 4 You're probably using
Try this instead:
Or, preferably, use DOM Manipulation:
Dom manipulation would be preferred compared to using
JakeParis 10.9k3 gold badges38 silver badges65 bronze badges answered Nov 21, 2012 at 14:11
CerbrusCerbrus 67.6k18 gold badges128 silver badges141 bronze badges 7 Working demo:
answered Oct 31, 2018 at 12:00
In most browsers, you can use a javascript variable instead of using
Then you can just refer to
See this snippet:
answered Aug 3, 2017 at 15:23
Ulysse BNUlysse BN 8,9657 gold badges48 silver badges76 bronze badges 0 you can also do like this
|