当元素里没有id和class,且不能通过元素直接找到怎么办?
用属性选择器!
示例代码:
<!DOCTYPE html>
<html>
<head>
<style>
a[target=_blank]
{
background-color:yellow;
}
</style>
</head>
<body>
<p>target="_blank" 的链接会得到黄色背景:</p>
<a href="http://www.w3school.com.cn">w3school.com.cn</a>
<a href="http://www.disney.com" target="_blank">disney.com</a>
<a href="http://www.wikipedia.org" target="_top">wikipedia.org</a>
<p><b>注释:</b>对于 IE8 及更早版本的浏览器中的 [<i>attribute</i>],必须声明 <!DOCTYPE>。</p>
</body>
</html>
博客提出当元素没有id和class,且不能通过元素直接找到时的解决办法,即使用属性选择器,并给出了示例代码,聚焦于前端元素查找的技术问题。
1210

被折叠的 条评论
为什么被折叠?



