JQuery selector: pass on id from array into function
- by user347256
I have a list of items
<div id="item1">somestuff</div>
<div id="item2">somestuff</div>
<div id="item3">somestuff</div>
When someone clicks on one of these, I need to take some actions based on the id (the number). Let's say hide it.
How can I make the function generic, and how can I pass the id into the function?
$(document).ready(function()
{
$("#item-howcanImakethisselectorgeneric?").click(function () {
$("#item-andhowcanIpasshteidintohere?").hide();
}
}
I'm a javascript/jquery newbie, any help (including rtfm) appreciated.