<div width="30%" height="60%" class="data-list aws-prio-h" style="cursor:pointer;" value="3087"></div>
<div width="30%" height="60%" class="data-list aws-prio-h" style="cursor:pointer;" value="3088"></div>
<div width="30%" height="60%" class="data-list aws-prio-h" style="cursor:pointer;" value="3088"></div>
如何使用value =“3087”
更改上面div的背景颜色我尝试了以下jquery代码
$(".data-list aws-prio-h value["3087"] ").css("background-color","red");
不工作
答案 0 :(得分:3)
.
,因为它是class selector []
- &gt; [Attribute = 'Value']
$(".data-list.aws-prio-h[value='3087']").css("background-color", "red");
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div width="30%" height="60%" class="data-list aws-prio-h" style="cursor:pointer;" value="3087">A</div>
<div width="30%" height="60%" class="data-list aws-prio-h" style="cursor:pointer;" value="3088">B</div>
<div width="30%" height="60%" class="data-list aws-prio-h" style="cursor:pointer;" value="3088">C</div>
&#13;
答案 1 :(得分:0)
jQuery上有CSS选择器错误。试试这个:
log="cd** /opt/logs"
这将完美无缺。
答案 2 :(得分:0)
检查以下代码
$( document ).ready(function() {
$('.data-list.aws-prio-h[value="3087"]').css("background-color","red");
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div width="30%" height="60%" class="data-list aws-prio-h" style="cursor:pointer;" value="3087">trest</div>
<div width="30%" height="60%" class="data-list aws-prio-h" style="cursor:pointer;" value="3088">xgdsfg</div>
<div width="30%" height="60%" class="data-list aws-prio-h" style="cursor:pointer;" value="3088">dsgdg</div>
&#13;
答案 3 :(得分:0)
$('.data-list[value="3087"]').css('background-color', 'red');