如何使用jquery获取其中包含值的标签的li? [英] How to get li which has a label with a value inside it with jquery?
本文介绍了如何使用jquery获取其中包含值的标签的li?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的页面中有一个无序列表,每个li里面都有一个名为lbl-colorID的标签,名为RpLblColorID,我在列表外面有一个输入,类名为sel-Color,名为LblSelColor 。现在我想选择具有RpLblColorID的li,其值等于LblSelColor值。如何在jquery中选择它?
I have a unordered list in my page and inside each li I have a label with class name "lbl-colorID" called "RpLblColorID" and I have an input outside the list with class name "sel-Color" called "LblSelColor". Now I want to select the li which has the "RpLblColorID" with the value equal to the "LblSelColor" value. How can I select it in jquery?
<ul class="thumb-ul">
<asp:DataList runat="server" ID="RptColor" DataSourceID="DSColor"
RepeatDirection="Horizontal" RepeatLayout="Table" > <ItemTemplate>
<a class="a-pnl-color" href="#">
<li class="thumb-div">
<div class="col-md-1">
<asp:label runat="server" ID="RpLblColorID" class="no-display lbl-colorID" Text='<%# DataBinder.Eval(Container.DataItem,"ColorID")%>' />
<asp:label runat="server" ID="RpLblColorCode" BackColor='<%# System.Drawing.ColorTranslator.FromHtml(Eval("ColorCode").ToString()) %>' Width="20px" Height="20px"></asp:label>
</div>
<div class="col-md-2">
<asp:Label runat="server" ID="RpLblColorName" CssClass="lbl-colorName" Text='<%# DataBinder.Eval(Container.DataItem,"ColorName")%>' ForeColor="Black"></asp:Label>
</div>
</li>
</a>
</ItemTemplate>
</asp:DataList>
</ul>
<input type="hidden" class="sel-color" runat="server" id="LblSelColor" name="LblSelColor" value="0" />
我尝试过:
它不起作用:
What I have tried:
it doesn't work :
$('ul.thumb-ul li :Label.lbl-colorID').filter(function () { return this.Text == $('.sel-color').val.toString() }).attr('class', 'thumb-div-sel');<pre>
推荐答案
('ul.thumb-ul li:Label.lbl-colorID')。filter(function() {return this.Text ==
('ul.thumb-ul li :Label.lbl-colorID').filter(function () { return this.Text ==
('。sel-color')。val.toString()})。attr('class','thumb-div-sel'); <预>
('.sel-color').val.toString() }).attr('class', 'thumb-div-sel');<pre>
这篇关于如何使用jquery获取其中包含值的标签的li?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文