javascript - Shopify Drop down Validation -
i'm building web store on shopify. want add validation dropdown if no size/value selected drop down, automatically select 1st size/value. when click on add cart button.
thanks help.
given html:
<select id="drop"> <option value="0">please select</option> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> <button id="add">add cart</button>
use javascript/jquery:
$(document).ready(function() { var $drop = $("#drop"); $("#add").on("click", function() { if($drop.val() == 0) { $drop.val(1); } }); });
Comments
Post a Comment