我有一些div在创建时动态添加“fund-id”属性,因为我的页面上可能有大约50个div。我试图动态地隐藏和显示元素的基础上的基金id和标签id的div的HTML将;
<div class="qtyDD" id="divqtyDD" style="display: none;" fund-id="1">
<a href="#" onclick="javascript:changeQtyType('D');"><label id="qtyTypeD" class="lblqtyDD" value="D">Dollars</label></a>
<a href="#" onclick="javascript:changeQtyType('Shrs');"><label id="qtyTypeShrs" class="lblqtyDD" value="Shrs">Shares</label></a>
<a href="#" onclick="javascript:changeQtyType('Full');"><label id="qtyTypeFull" class="lblqtyDD" value="Full">Full</label></a>
<a href="#" onclick="javascript:changeQtyType('Net');"><label id="qtyTypeNet" class="lblqtyDD" value="Net">Net Redemptions</label></a>
</div>
根据复选框的选择,我想要隐藏();最后3个元素或全部显示。类似的东西;
var fundID = fundID (taken from the function call, this is working fine)
if(this.checked){
$('#divqtyDD[fund-id="' + fundID + '"]').next('#qtyTypeShrs').hide();
}else{
$('#divqtyDD[fund-id="' + fundID + '"]').next('#qtyTypeShrs').show();
}
标签在被下一个功能引用时不会隐藏。任何帮助都是感激的。
2条答案
按热度按时间jfgube3f1#
尝试
或者你可以直接使用
因为ID是唯一的。
fhity93d2#