我想定位所有从tab_btn(数字)
开始的具有buttonid的按钮有没有办法以这种方式选择css中的元素。我不能使用jquery,因为CSS只是限制。
<input id="FormControl_V1_I1_S1_I1_B1" scriptclass="Button" class="dh_LmyGLHecqegKZ42V_0 dj_LmyGLHecqegKZ42V_0" formid="FormControl" originalid="V1_I1_S1_I1_B1" tabindex="0" title="" buttonid="tab_btn1" value="General" type="button">
<input id="FormControl_V1_52_J1_I1_B1" scriptclass="Button" class="dh_LmyGLHecqegKZ42V_0 dj_LmyGLHecqegKZ42V_0" formid="FormControl" originalid="V1_I1_S1_I1_B1" tabindex="0" title="" buttonid="tab_btn2" value="General" type="button">
类和其他属性在这里不会是常量,但ID将有一个系列启动tab_btn1,tab_btn2等
答案 0 :(得分:2)
只需将[id^="tab_btn"]
作为选择器。它将定位以tab_btn
答案 1 :(得分:1)
检查此示例:
为所有具有以&#34开头的类属性值的元素设置背景颜色;测试&#34;:
div[class^="test"] {
background: #ffff00;
}
答案 2 :(得分:0)
css中的属性选择器。 [attribute ^ =&#34; value&#34;] 选择器用于选择属性值以指定值开头的元素。
input[buttonid^= "tab_btn"] {
background: yellow;
}
&#13;
<input id="FormControl_V1_I1_S1_I1_B1" scriptclass="Button" class="dh_LmyGLHecqegKZ42V_0 dj_LmyGLHecqegKZ42V_0" formid="FormControl" originalid="V1_I1_S1_I1_B1" tabindex="0" title="" buttonid="tab_btn1" value="General" type="button">
<input id="FormControl_V1_52_J1_I1_B1" scriptclass="Button" class="dh_LmyGLHecqegKZ42V_0 dj_LmyGLHecqegKZ42V_0" formid="FormControl" originalid="V1_I1_S1_I1_B1" tabindex="0" title="" buttonid="tab_btn2" value="General" type="button">
<input id="FormControl_V1_H2_M1_I1_B1" scriptclass="Button" class="dh_LmyGLHecqegKZ42V_0 dj_LmyGLHecqegKZ42V_0" formid="FormControl" originalid="V1_J1_T1_I1_B1" tabindex="0" title="" buttonid="tab2" value="General" type="button">
&#13;