简体   繁体   中英

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;

How can I select "Position", if I have many element with name "Position", but any position have unique "Identity", for example its identity now equal to 5.

I cant use "contains" because I dont need select "55" or "85" or "15", I need select only "5"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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