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> 

http://jsfiddle.net/lkkbz/

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

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -