Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⛽️第5期第5题:insertAdjacentHTMLinsertAdjacentElement的区别 #34

Open
LinDaiDai opened this issue Jun 23, 2020 · 1 comment
Labels

Comments

@LinDaiDai
Copy link
Owner

insertAdjacentHTMLinsertAdjacentElement的区别

第二个参数的类型不同, 前者接收的是是要被解析为HTML或XML元素的字符串,而后者接收的是一个element元素。

const one = document.getElementById('one');
one.insertAdjacentHTML('afterend', '<div id="two">我是two</div>');

const one = document.getElementById('one');
const two = document.createElement('div')
two.innerHTML = '我是two';
one.insertAdjacentElement('afterend', two);
@LinDaiDai LinDaiDai added the HTML label Jun 27, 2020
@wwELi
Copy link

wwELi commented Nov 26, 2021

问一下 insertAdjacentHTML 和innerHtml 这两者有什么区别?看着表现形式一样的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants