There is a markup:
<div class="product-item"> <a href="#" class="product-item-img-wrap"> <img src="фото" alt="item"/> </a> <div class="item-eq-height item-info"> <div class="product-name"> <h5 class="product-item-header" style="font-size: 18px; font-weight: bold;"> Наименование </h5> </div> <div class="product-item-size" style="font-size: 14px;"> Размер и артикуль:<br /><br /> <select style="width: 224px;" name="size"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> </div> <div class="product-item-price"> Цена </div> <div class="btn-wrap prod-buy-button"> <span class="btn-solid btn-add-cart" onclick="addCart(this);" style="cursor: pointer;">Купить</span> <input type="hidden" value="<?=$produсt->id?>" name="id"/> </div> </div> </div>
In this block there is a <select name="size">
. How to access it by clicking the "Buy" button?
I do this, but it does not work:
function addCart(btn) { $this = $(btn); var id = $this.siblings('input[name=id]').val(); var size = $this.closest('.product_list').find('select[name="size"]').val(); alert(size); }