How to add text on first td when click <a> tag inside other td...
Hi All
I am trying to make a shopping site and when a user click "add to cart" button, a "this item has been added" text will show up next to the product title.
My html code
- <div id="product">
- <table width="594" border="0" cellpadding="5" cellspacing="0">
- <tr>
- <td><img src="<?php echo "$brandImage"; ?>" width="100" height="40"/></td>
- <td colspan="3" valign="middle"><strong><?php echo $productName; ?></strong> //place to show the text "item is in the cart"
- </td>
- </tr>
- <tr>
- <td><img src="<?php echo $productThumb; ?>" width="180" height="135"></td>
- <td width="303" align="left" valign="top"><ulid="feature">Feature...</td>
-
- <td> <a href="productDisplay.php?productId=<?php echo $productId;?>">
- <img src="images/iconBullet.jpg" width="10" height="18"> View Detail</a><br>
- <span id="wasPrice"><?php echo $productPriceWas; ?></span>
- //button to click
- <a id="addToCart" href="javascript:void(0);" onclick="addToCart()">
- <img src="images/addToCart.gif" alt="add To Cart"/><a/>
- </td>
- </tr>
- </table>
- </div>
I use this jquery code but it only works on the first table (My code generates 1 item per table from mysql). The second and the third one is not working. Here is my Jquery
- $(document).ready(function(){
- $("#addToCart").click(function(e){
- $(e.target).parent().parent().parent().parent().find("td:eq(1)").append(" hohoho");
- });
- });
I want the text only append once on every table (for different product). I would really appreciate it if someone enlighten me......Thanks!