我们如何使用jQuery选择器eq :()?
如果要选择具有特定索引的元素,请使用jQuery选择器eq()。在这里,设置索引号以选择元素。
示例
您可以尝试运行以下代码来学习如何使用jQuery选择器eq():
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p:eq(1)").css("background-color","red");
});
</script>
</head>
<body>
<h1>Heading 1</h1>
<p class="myclass">This is demo text.</p>
<p>This is another text.</p>
<p>This is demo content</p>
</body>
</html>热门推荐
10 祝女儿结婚简短祝福语
11 幼儿祝福语大全简短贺卡
12 新年祝福语简短俏皮文案
13 新年酒会祝福语简短创意
14 牛年大气简短的祝福语
15 精简祝福语简短小故事
16 校庆祝福语简短横幅
17 给新生的简短祝福语
18 出车开工吉祥祝福语简短