Skip to content Skip to sidebar Skip to footer

Get Product Name From Parent Element

Here I am trying to get the product name in alert box when the 'Buy now' button is clicked. Also I need to maintain the onclick event of the button for which I have placed the code

Solution 1:

Change this:

var text = $(this).parents(".item").find('.product-name').text();  

Solution 2:

here is answer

var text = $(this).parents('li').first().find('.product-name').text();

http://jsfiddle.net/LkKbz/1/

Post a Comment for "Get Product Name From Parent Element"