jquery nth-child append (first and second dd in dl) 麻烦

jquery nth-child append (first and second dd in dl) trouble

正在尝试 select dl 中的第一个/第二个 dd,为它们添加一个

HTML:

<dl> <dt></dt> 
    <p></p>
    <dd></dd>
    <dd></dd>
</dl>

JS(Jquery):

$("dl dd:nth-child(1)").after("<sub>md</sub>");
 $("dl dd:nth-child(2)").after("<sub>lg</sub>");

Js Fiddle

我怎样才能完成一个以上的 dl?我必须使用 .each 吗?

谢谢!

只需使用 nth-of-type 即可将其添加到所有(您的 fiddle 也不是 运行 jquery)

$("dl dd:nth-of-type(1)").after("<sub>md</sub>");
$("dl dd:nth-of-type(2)").after("<sub>lg</sub>");

FIDDLE