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

My HTML document is not linking to my CSS stylesheet properly -

php array slice every 2th rule -

node.js - Sending sockets to client side, Error: Converting circular structure to JSON -