html:
<ul>
<li>1</li>
<li>1</li>
<li id="one">1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
js:
var oli= document.getElementById("one");;
oli.style.color = "red";
function siblings(item) {
var p = item.parentNode.children;//获取父级所有子集元素
for (var i = 0, pl = p.length; i < pl; i++) {
if (p[i] !== item) { //删除自己
p[i].style.color = "gray"; //执行事件
}
}
}
siblings(oli);