0
我試圖提取GTM中的產品描述標記的全部文本(部署結構化數據,yada yada)。我面臨的問題是,我試圖提取的文本的一半存在於產品頁面上的「Read More ...」鏈接中。在「ReadMore ...」觸發器中連接文本
頁面上的元素的佈局已呈現後是:
<p class="product-description">
"This is the first part of the description of this product! It is read, warm,"
<span class="morecontent" display="inline"> //inline when expanded, none when clicked
<span class="readmore-description">
"fuzzy, and black."
</span>
<a class="more-link">&nsbp;Less</a> //&nsbp;Less when expanded, &nsbp;Read More.. when clicked
</span>
</p>
我沒有得到遠......所有到目前爲止,我已經試過是:
function() {
var description = document.querySelector("p.product-description");
return description;
}
我想得到「這是這個產品的第一部分描述!它被讀取,溫暖,模糊和黑色。」背部。
謝謝!
感謝這個 - 我認爲這是類似於頁面是如何架構已經。你知道我怎樣才能用一個函數來提取完整的描述(不是分成兩部分)嗎? 'function(){ var description = document.querySelector(「p.product-description」); return description; }'是我現在使用的,但當然不起作用。我認爲腳本需要以某種方式連接。 – PercentSharp
僅當您分別提取它們,然後將它們連接到一個字符串中。 – zsawaf