<img name="imageUrl" th:src="${item.imageUrl}" alt="메뉴 이미지">
<h3 name="productName" th:text="${item.productName}"></h3>
<p name="description" th:text="${item.description}"></p>
<span name="price" th:text="${item.price}">가격: 10,000원</span>
$(".add-to-cart-button").on("click", function () {
const $menuItem = $(this).closest(".menu-item");
const productId = $menuItem.find("span[name='productId']").text();
const productName = $menuItem.find("h3[name='productName']").text();
const price = $menuItem.find("span[name='price']").text();
}
const $menuItem = $(this).closest(".menu-item");
사용해서 가져올 수 있다.
잘 봤습니다. 좋은 글 감사합니다.