[英]jQuery XML parsing: select all nodes containing a certain tag with a certain value
假設XPath是“ /bookstore/book[price=35.00]”(來自w3示例)。
這是我到目前為止所走的路。
https://jsfiddle.net/npvgfzwc/
var name = src.find("bookstore book:has(price:contains('35.00')) title").text();
我可以得到它含有 35.00價格選擇的書籍,但不能找到一種方法,使之完全匹配的。 有沒有辦法做到這一點?
您需要使用:
var name=src.find("bookstore book price").filter(function(){
return $(this).text()=="35.00"
}).prev().text();
$('#blah').text(name);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.