找找文档,应该是 this.parentNode.previousSibling
但是返回的不是对象而是 text...
怎么获取父节点的上一兄弟节点呢
找找文档,应该是 this.parentNode.previousSibling
但是返回的不是对象而是 text...
怎么获取父节点的上一兄弟节点呢
1
just1 OP 0
|
2
Keita1314 Jan 28, 2016 previousElementSibling 而不是 previousSibling
|
3
Keita1314 Jan 28, 2016 Notes
Gecko-based browsers insert text nodes into a document to represent whitespace in the source markup. Therefore a node obtained, for example, using Node.firstChild or Node.previousSibling may refer to a whitespace text node rather than the actual element the author intended to get. See Whitespace in the DOM and W3C DOM 3 FAQ: Why are some Text nodes empty? for more information. |
5
Roycom Jan 28, 2016
mark
|
6
pysama Jan 28, 2016 @just1
对于不支持 previousElementSibling 的浏览器。循环获取 previousSibling ,直到其 nodeType 为 1 |
7
westpsk Jan 28, 2016
我只想问为什么要用裴博士作为头像
|