Hello,

I'm still learning jquery and I was wondering how to work with dynamic links

So say I have a while loop, and inside theres a link something like this:

while($row = mysql_fetch_array($sql_query)
$test = $row['id'];
{
   echo "<a href='".$test.php."'>".$test."</a>";

}

I want to be able to click on the links but with each link do something based on jquery

$(document).ready(function(){
$test.click(function(){
//code
});
});

I'm not sure??

Thank you

first of all: the url isn't right, if you want to get like: $test = 1 =>1.php and $test = 2 => 2.php this works:

while($row = mysql_fetch_array($sql_query)
$test = $row['id'];
{
   echo "<a href='".$test.".php"'>".$test."</a>";
 
}

seconddly $test will not access the link, you have to set a id to your link, to do this click-function only with that unique link or use the element "a" to do this with all links:

a-Version:

$(document).ready(function(){
$("a")click(function(){
//code
});
});

ID Version:

$(document).ready(function(){
$("#link")click(function(){
//code
});
});

and then add id="click" to the a-Element