如何获取所有不带id属性的tr元素?
<tr id="name">...</tr>
<tr>...</tr>
<tr>...</tr>
谢谢
Answers:
你能试一下吗 //tr[not(@id)]?
if (elm.hasAttribute('id')) {
//if id - implement here
} else if (elm.hasAttribute('class')) {
//if class - implement here
} else {
for (i = 1, sib = elm.previousSibling; sib; sib = sib.previousSibling) {
if (sib.localName == elm.localName)
i++;
};
segs.unshift(elm.localName.toLowerCase() + '[' + i + ']');
}