繁体   English   中英

jQuery通过文本查找并选择元素的父项,但不包含

[英]jQuery find and select parent of element by text BUT NOT CONTAINS

<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;

如果我有很多名称为“ Position”的元素,但是任何职位都有唯一的“ Identity”,例如现在其身份等于5,如何选择“ Position”。

我不能使用“包含”,因为我不需要选择“ 55”或“ 85”或“ 15”,我只需要选择“ 5”

var $pos5 = $("position").filter(function(){ 
  return $(this).find("Identity").text() == "5"; 
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM