前提・実現したいこと
・以下のHTMLから 72円 というテキストのみ抜き出したいと考えています。
html
1<p class="product-cart-price"> 2 <span class="only-sp product-cart-small-text">小計(税込)</span> 3 72円 4</p>
恐れ入りますが、もしお分かりの方がいらっしゃればご教授頂けますと幸いです。
試したこと・発生している問題
以下では undefined になってしまいました。
js
1console.log($(".product-cart-price>:not(span)").text()); 2$(".product-cart-price>:not(.product-cart-price>span)").text()
以下では 小計(税込) 72円 と出力されてしまいました。
js
1console.log($(".product-cart-price:not(span)").text());
補足情報(FW/ツールのバージョンなど)
・jQuery v3.3.1 を使用しています。
回答4件
あなたの回答
tips
プレビュー