Easy. jQuery will let you bind a given function to many items on the page. Suppose you had table rows as follows:
Code:
<table id="myTable">
<tr><td><a href="#" id="uniqueID_1">Link 1</a></td></tr>
<tr><td><a href="#" id="uniqueID_2">Link 2</a></td></tr>
<tr><td><a href="#" id="uniqueID_3">Link 3</a></td></tr>
<tr><td><a href="#" id="uniqueID_4">Link 4</a></td></tr>
<tr><td><a href="#" id="uniqueID_5">Link 5</a></td></tr>
</table>
You could bind a function to the click event like so:
Code:
$(document).ready(function() {
$("#myTable a").click(function(e) {
e.preventDefault(); // Stop the normal behavior that would happen with a click
// Use $(this) to act upon the link that was clicked
alert("The ID of the clicked link is " + $(this).attr("id"));
// Change the background color of the clicked row
$(this).closest("tr").css("background-color", "red");
});
});
Hopefully that gets you pointed in the right direction.
Bookmarks