How would I select the first element in the following with jQuery? heading 6条回答 忘掉有多难 (楼主) 2021-01-03 19:33 You almost know the answer (from your post title). There is a selector in jQuery called :first-of-type. Use it to find and add class to the first p tag automatically, like so: $("div p:first-of-type").addClass('someClass'); 0 讨论(0) 查看其它6个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复
with jQuery? heading 6条回答 忘掉有多难 (楼主) 2021-01-03 19:33 You almost know the answer (from your post title). There is a selector in jQuery called :first-of-type. Use it to find and add class to the first p tag automatically, like so: $("div p:first-of-type").addClass('someClass'); 0 讨论(0) 查看其它6个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复
heading
You almost know the answer (from your post title). There is a selector in jQuery called :first-of-type. Use it to find and add class to the first p tag automatically, like so:
:first-of-type
$("div p:first-of-type").addClass('someClass');