CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   how to add unique classes to a div (http://www.codingforums.com/showthread.php?t=260890)

jon22 05-10-2012 08:18 PM

how to add unique classes to a div
 
basically my end goal is to hide a voucher code then reveal when clicked and open the url in a new window,

my first problem is the way the site is coded, i can't use a single jquery function because all of the instances will have the same ID/Class, so the action will cause all of the divs to reveal no matter which one is clicked.

so i need to give each div id a unique class,

here is my code:

Code:

<script>
        $("#revealVoucher").click(function () {
    $("#voucherCode").show("slow");
    });
</script>

Code:

<div id="revealVoucher" >
    <a href="<?=$affiliate_url?>" target="_blank">Reveal Code</a>
</div>

<div id="voucherCode">
    <a href="<?=$affiliate_url?>"><?=$voucher_code?></a>
</div>

this would be perfect if each instance of this code could be given a unique class and this is where i am stuck, how could I give both ID's (revealVoucher / voucherCode) these classes, eg revealVoucher_01, revealVoucher_02 in order for them to work independently?


All times are GMT +1. The time now is 10:25 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.