反正有没有创建一个字符串并添加到DOM?并使用Javascript来理解字符串中的元素?
I tried the below and 4th line gives error:
var bmdiv = document.createElement('div');
bmdiv.setAttribute('id', 'myDiv');
var str = "<b>aa</b>";
bmdiv.innerHTML(str);
Run Code Online (Sandbox Code Playgroud)
我需要在str中为DIV myDiv添加几个标签
我不需要使用jQuery,因为脚本不会加载jQuery谢谢.