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

复制节点应该是cloneNode 吧? #1065

Open
15938265525 opened this issue Oct 30, 2021 · 0 comments
Open

复制节点应该是cloneNode 吧? #1065

15938265525 opened this issue Oct 30, 2021 · 0 comments

Comments

@15938265525
Copy link

1.节点查找

  • document.getElementById,document.getElementByTagName,document.getElementByName ,- document.getElementByClassName
  • document.querySelector() 参数为选择器
  • document.forms 选取页面中的所有表单元素

2.增加节点

增加节点前必须先使用document.createElement()创建元素节点,参数为标签名

  • m.appendChild(n) 为m元素在末尾添加n节点
  • m.insertBefore(k,n) 在m元素的k节点前添加n节点

3.删除节点

  • m.removeChild(n)删除m元素中的n节点
  • m.replaceChild(k,n)用n节点取代m元素中的k节点

4.复制节点

  • m.cloneChild() 复制m节点,并将复制出来的节点作为返回值
    参数为true时,则将m元素的后代元素也一并复制。否则,仅复制m元素本身

Originally posted by @lvanboy in #175 (comment)

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

No branches or pull requests

1 participant