[英]navigating to prev element using jQuery
我在具有fieldValidation类的元素(在下面绑定)。 并尝试导航到.fTitleCell
内的label字段。
这就是我在做什么。
$(".fieldValidation").each(function(){
console.log($(this).prev("fTitleCell").text);
});
fTitleCell和fInputCell的模式适用于多个字段,并且对于每个fInputCell,我需要遍历最接近的fTitleCell并获取其标签。
<div class="fRow">
<div class="fTitleCell">
<input id="mainForm:j_idt139" type="checkbox" name="mainForm:j_idt139" class="checkbox-Access">
<label onmouseover="FA.fixLabelFor(this);">*IP Address*</label>
</div>
<span class="fInputCell searchField-ip_int" style="width:25.0%;">
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:ga="http://gfs.com/">
<input type="text" name="mainForm:j_idt139" value="" class="fieldValidation" onblur="filter.setAdvCheckBox(this);" onkeyup="validation.checkType(this, 'ADDR');">
</div>
</span>
</div>
你需要回到父母身边。 然后到之前的兄弟元素,然后寻找标签。
$(".fieldValidation").each(function(){
console.log($(this).parents('.fInputCell').prev('.fTitleCell').find('label').text())
});
$(".fieldValidation").each(function(){
var $parentRow = $(this).closest('.fRow');
var label = $parentRow.find('.fTitleCell label');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.