I have a while loop that creates a list of binding tags, each of which has a unique class name, counting from 1 to any number of elements. I would like to change the css attriubute to a specific tag and anchor class when it is clicked, so lets say that the background color is changed. Here is my code
while($row = mysql_fetch_array($results)){
$title = $row['title'];
$i++;
echo "<a class='$i'>$title</a>
}
I would like my jquery to look something like this, it will obviously be more complicated than that. I just got confused how to start.
$(document).ready(function() {
$('a .1 .2 .3 .4 and so on').click(function() {
$('a ./*whichever class was clicked*/').css('background':'red');
});
});
source
share