javascript - Get product name from parent element -
here trying product name in alert box when "buy now" button clicked. need maintain onclick event of button have placed code in jquery.
<h2 class="product-name"><a href="product1.php" title="sample product name">sample product name</a></h2>
the approach did giving me blank alert box might because calling parent element. please help
please note here don't want alert when product name or image clicked. want on button
change this:
var text = $(this).parents(".item").find('.product-name').text();
Comments
Post a Comment