# :last-of-type 和 :first-of-type的誤用
someselector:last-of-type不僅與someselector這個選擇器相關,還與符合該選擇器的元素的標簽相關。
再看一下W3C的說明:
> The :last-of-type pseudo-class represents an element that is the last sibling of its type in the list of children of its parent element.
>
這里所謂 the last sibling of its type其實講得并不是很清楚,但仔細琢磨,這里的type的意思應該就是不僅僅與選擇器相關,還與標簽相關。
<iframe width="100%" height="300" src="//jsrun.net/GBiKp/embedded/all/light/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
從中可以看出,選擇器首先會找到父元素下相同的標簽,如果class相同,則選中,否則不會選中。