【发布时间】:2020-10-10 05:03:27
【问题描述】:
在自定义的 javascript 变量中,如何获取被点击元素的第三个父元素,然后下到子元素? 我需要从这个例子中得到 price (437,00) 的值。
点击按钮的选择器:#addToCartForm3V1061551 > button > span
我需要获取的价格选择器:body > main > div.main__inner-wrapper.js-main-inner-wrapper > div.main__content > div.page-content > div.page-content-main > div > div:nth-child(1) > div > div > div.owl-wrapper-outer > div > div:nth-child(2) > div > a > div > div.product-teaser__details.product-teaser--price-discount > div > div.product-teaser__bottom > div.product-teaser__price-block > div.product-teaser__price > span.price-without-discount
我已经尝试过这个答案的变体:https://stackoverflow.com/a/44316348/10363442 但没有运气......
function(){
var title = jQuery({{Click Element}}).parent().find('h2').html();
return title;
}
【问题讨论】:
标签: javascript jquery google-tag-manager