ボタンクリックで親クラスから値を取り込むためにJavaScriptを使用する際に問題が発生しています。私は、ボタン選択でjavascriptを起動し、Domツリーを登り、 "product-sku"クラスから値を引き出す必要があります。この投稿を掘り下げた後、https://gomakethings.com/climbing-up-and-down-the-dom-tree-with-vanilla-javascript/私はボタン選択でスクリプトを序文にしなければならないことを知っていますが、私はこの考え方を木のように動かすことができないのでしょうか?GTMのJavascriptの親クラスから値を引き出す
<div class="review-sku-line">
<div class="ratings">
<span class="amount"><a href="#" onclick="var t = opener ? opener.window : window; t.location.href='xxxx/review/product/list/id/123456/category/117/'; return false;">No Reviews</a></span>
</div>
<div class="product-sku">
<span><strong>Code:</strong> 7777</span>
</div>
</div>
<div class="actions">
<form class="add-form cart-update-flag" method="post" action="xxxxx/checkout/cart/add/uenc/aHR3dUuaHRtbA,,/product/123456/form_key/cV1MQZ1w/">
<input type="hidden" name="block_name" value="xxxxxx/_list_item_render_gridview">
<div class="qty-control small">
<button type="button" for="qty_prod_123456" class="qty-ctrl-sub button">
<span class="grey-btn"><i class="icon-minus"></i></span>
</button>
<input id="qty_prod_123456" type="text" class="qty" name="qty" value="1">
<button type="button" for="qty_prod_123456" class="qty-ctrl-add button">
<span class="orange-btn"><i class="icon-plus"></i></span>
</button>
</div>
<button class="button btn btn-cart" title="Add to Cart" type="submit">
<span>Add to Cart</span>
</button>
</form>
</div>
</div>
ありがとうございました。何かアドバイスやアドバイスありがとうございました!