English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
:last-of-type選択子は、親要素の特定のタイプの最後の子要素であるすべての要素を選択します。
これは:nth-last-of-type(1)と同じです。
を使用して、:first-of-type選択子は、親要素の特定のタイプの最初の子要素であるすべての要素を選択できます。
$(":last-of-$("type")
親の要素の最後の<p>要素に属するすべての<p>要素を選択します:
$("document").ready(function(){ $("p:last-of-type").css("background", "coral"); });テストをしてみて‹/›
すべての<div>要素内の最後の<p>要素を選択します:
$("document").ready(function(){ $("div p:last-of-type").css("background", "coral"); });テストをしてみて‹/›