如何选择ID以特定字符串开头和结尾的所有元素? [英] How to select all elements whose ID starts and ends with specific strings?
本文介绍了如何选择ID以特定字符串开头和结尾的所有元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何选择所有< tr>
元素,其 id
以部分_
,结尾为 _dummy
?
How can I select all <tr>
elements where their id
begins with section_
and ends with _dummy
?
我想选择以下< tr>
s:
<tr id="section_5_1_dummy">
<td>...</td>
</tr>
<tr id="section_5_2_dummy">
<td>...</td>
</tr>
推荐答案
以下CSS3选择器将执行此操作: p>
The following CSS3 selector will do the job:
tr[id^="section_"][id$="_dummy"] {
height: 200px;
}
^
$
表示 id
应以结尾。
id
当应用于(例如)< a>
时,可以用另一个属性,例如 href
id
itself can be replaced with another attribute, such as href
, when applied to (for example) <a>
:
a[href^="http://www.example.com/product_"][href$="/about"] {
background-color: red;
}
这篇关于如何选择ID以特定字符串开头和结尾的所有元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文