skip to Main Content

Printing value of custom attributes on multiple divs – Shopify

I am working on a Shopify store where there are multiple divs like below: <div class="options-selection__option-values" data-variant-option="" data-variant-option-index="0" data-variant-option-chosen-value="One"></div> <div class="options-selection__option-values" data-variant-option="" data-variant-option-index="0" data-variant-option-chosen-value="Two"> <div class="options-selection__option-values" data-variant-option="" data-variant-option-index="0" data-variant-option-chosen-value="Three"> <div class="options-selection__option-values" data-variant-option="" data-variant-option-index="0" data-variant-option-chosen-value="Four"> I want to get the value…

VIEW QUESTION

How to Select all buttons and alert their respective name when CLICKED in jQuery

$("button").on("click", function(){ var buttonClicked = $("button").attr("name"); alert("Button CLicked: " + buttonClicked); }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <h1 class="titleClass">jQuery</h1> <div class="buttonClass"> <button name="up_button" id="upB" class="upDown"></button> <button name="left_button" id="leftB" class="leftRight"></button> <button name="right_button" id="rightB" class="leftRight"></button> <button name="down_button" id="downB" class="upDown"></button> </div> I want to display the…

VIEW QUESTION
Back To Top
Search