开发者

How to set elements html content from a string using JS?

Before:

<div id="foo"></div>

开发者_C百科After:

<div id="foo"><a href="www.stackoverflow.com">best site eva</a></div>

How to accomplish this with pure JS (no jQuery)?


There are a number of ways, probably the simplest is

document.getElementById("foo").innerHTML = '<a href="www.stackoverflow.com">best site eva</a>';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜