Javascript jQuery按文本查找并选择元素的父元素,但不包含 5 8. 让Identity=$(this.find(“Identity”).text()//这等于5 让widedt=$(wBody).find(“Position”).children(“Identity”).text()==Identity;
如果我有许多名为“Position”的元素,但任何位置都有唯一的“Identity”,例如,它的Identity现在等于5,那么如何选择“Position”Javascript jQuery按文本查找并选择元素的父元素,但不包含 5 8. 让Identity=$(this.find(“Identity”).text()//这等于5 让widedt=$(wBody).find(“Position”).children(“Identity”).text()==Identity;,javascript,jquery,Javascript,Jquery,如果我有许多名为“Position”的元素,但任何位置都有唯一的“Identity”,例如,它的Identity现在等于5,那么如何选择“Position” 我不能使用“包含”,因为我不需要选择“55”或“85”或“15”,我只需要选择“5”我认为你的意思不是真的,是吗?那看起来一点也不像jq。你的意思是?亚历克斯,请简要说明你的问题。 <position><Identity>5</Identity></position> <position
我不能使用“包含”,因为我不需要选择“55”或“85”或“15”,我只需要选择“5”我认为你的意思不是真的,是吗?那看起来一点也不像jq。你的意思是?亚历克斯,请简要说明你的问题。
<position><Identity>5</Identity></position>
<position><Identity>8</Identity></position>
let Identity = $(this).find("Identity").text(); //this equal 5
let wIdent = $(wBody).find("Position").children("Identity").text() == Identity;
var $pos5 = $("position").filter(function(){
return $(this).find("Identity").text() == "5";
});