That is how it suppose to work.The :first
pseudo-class is equivalent to :eq(0)
. It could also be written as :lt(1)
. While this matches only a single element, :first-child
can match more than one: One for each parent.
Try this:
$("table tr.b:first").before("<tr><td>css selector</td></tr>");
OR
$("table tr.b:eq(0)").before("<tr><td>css selector</td></tr>");