如何仅定位类为“Cover”的元素,而不定位类多于Cover的元素。使用getElementsByClassName,我无法找到一种方法,使其不同时查找具有“Cover”类和“placeholder”类的元素。
此外,我还质疑第二类“占位符”的正确术语是什么。我们是将该类称为子类,还是仅仅是元素上的第二个类?
<div>
<a class="Cover" href="javascript:void(0);" tabindex="1" aria-label="First Name: firstName" style="height: 38px; left: 26px; width: 1035px; top: 274.375px;"></a>
<a class="Cover" href="javascript:void(0);" tabindex="2" aria-label="Last Name: lastName" style="height: 38px; left: 26px; width: 1035px; top: 314.375px;"></a>
<a class="Cover" href="javascript:void(0);" tabindex="3" aria-label="Suffix: Suffix" style="height: 38px; left: 26px; width: 1035px; top: 354.375px;"></a>
<a class="Cover place-holder" href="javascript:void(0);" tabindex="10" style="height: 34px; left: 26px; width: 1035px; top: 634.375px;"></a>
<a class="Cover" href="javascript:void(0);" tabindex="20" aria-label="Gender: Gender" style="height: 108px; left: 26px; width: 1035px; top: 1619.75px;"></a>
</div>
简单的Javascript:
document.getElementsByClassName("Cover");
// finds five elements. How do I tell it to find ONLY elements having the Cover Class?