我有以下代码:
<div class="sc-gPEVay JHVSz" data-locator="category" data-values="9AAF500002"><button class="sc-jWBwVP mdc-ripple-surface ebJHFF" data-locator="category-header" style="align-items: stretch; background-color: rgba(0, 0, 0, 0); border-color: rgba(0, 0, 0, 0); border-style: none; box-shadow: none; color: rgb(114, 114, 114); cursor: pointer; display: flex; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 13px; line-height: inherit; font-family: inherit; margin: 0px; outline: none; padding: 0px; text-decoration: none; width: 100%;"><i aria-hidden="true" class="sc-brqgnP material-icons_mi_2breL5T5PilQnhNwuNJjVT material-icons_mi-arrow-drop-down_1Yg8_MNgX_6a8ed5ZighLw ygVYg" data-locator="category-expander" style="height: 24px; margin-right: 12px; transition: transform 175ms ease 0s; transform: rotate(-90deg);"></i><div class="sc-cMljjf bIKLMh" data-locator="category-label" style="font-family: Verdana, Arial, sans-serif; margin-top: 4px; min-height: 24px; text-align: left;"> My Text </div></button><div class="sc-jDwBTQ kFDQOY" data-locator="category-children" style="margin-left: 10px;"></div></div>
无论点击到何处,我想要实现的都是返回文本“我的文本”。
我尝试过:
function (){
var $clickElement = $({{Click Element}});
var $x = $clickElement.closest('i').find('div');
return $x.text();
PS。我不能/不想使用这些类(它们可以更改)