使用Next()按类别获取自定义属性值
问题描述:
我正在寻找按类使用next()获取图像中自定义属性的值。使用Next()按类别获取自定义属性值
$("#chkSell").live('change',function(){
var posType = $(this).next('img[class="qtyImgDD"]').attr('posType');
});
<div class="Sell" style="width: 47px;"><input type="checkbox" fund-id="1" id="chkSell" class="_1"/></div>
<div class="Buy" style="width: 47px;"><input type="checkbox" fund-id="1" id="chkBuy" class="_1"/></div>
<div class="BuySelllbl" style="width: 10px;"><label class="lblBuySell_1" fund-id="1"> </label></div>
<div class="Amt" style="width: 116px;"><input type="textbox" fund-id="1" id="AmtValue" size="8" disabled="disabled"/></div>
<div class="QtyType" style="width: 55px;"><label class="lblQtyType" fund-id="1" ddclass="_1">D</label>
<img src="/Applications/Images/ModelManagement/DropDown_Disabled.gif" fund-id="1" posType="MutualFund" class="qtyImgDD" disabled="disabled" ddclass="_1"/></div>
我想要的是,当有人点击chkSell复选框并颁布的变化()函数来获得posType从属性值在底部?
答
有一些小的事情,你可能想改变。将“live”切换到“on”,将“next”切换到“nextAll”,将“img [class =”qtyImgDD“]”更改为img.qtyImgDD。
$("#chkSell").on('change',function(){
var posType = $(this).parent().nextAll('.QtyType').find('img.qtyImgDD').attr('posType');
});
Next
是只顾眼前的兄弟姐妹,其中作为nextAll
是以下所有的兄弟姐妹。
此外,您所拥有的标记没有将您定位为直属兄弟的元素。所以你需要遍历他们的父母。
编号:
+0
这很好,非常感谢您的帮助,我会在nextAll文档上做更多的阅读,但我对此并不熟悉。 –
你面对什么样的问题?。 – Rex
当我明确地问了一个问题并用正确的代码引用和HTML表达我的问题时,为什么你会低估我的观点? –