如何在元素列表中选择某个元素?我有以下:
<div class="myclass">my text1</div> <!-- some other code follows --> <div> <p>stuff</p> </div> <div> <p>more stuff</p> </div> <p> <span>Hello World</span> </p> <div class="myclass">my text2</div> <!-- some other code follows --> <div> <p>stuff</p> </div> <p> <span>Hello World</span> </p> <input type=""/> <div class="myclass">my text3</div> <!-- some other code follows --> <div> <p>stuff</p> </div> <footer>The end</footer>
我有CSS类div.myclass {做事}适用于所有,显然,但我也想要能够选择类.myclass的第一,第二或第三个div这样,无论他们在标记:
div.myclass:first {color:#000;} div.myclass:second {color:#FFF;} div.myclass:third {color:#006;}
几乎像jQuery索引选择.eq(索引),这是我目前使用,但我需要一个无脚本的选择。
解决方法
原文地址:https://www.jb51.cc/css/222037.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。