Passing data to a jQuery click() function
- by jakenoble
Hi
I have a simple span like so
<span class="action removeAction">Remove</span>
This span is within a table, each row has a remove span.
And then I call a URL using AJAX when that span is clicked. The AJAX event needs to know the ID of the object for that row? What is the best way of getting that ID into the click function?
I thought I could do something like this
<span class="action removeAction" id="1">Remove</span>
But an ID should not start with a number? Right? Then I thought I could do
<span class="action removeAction" id="my1">Remove</span>
Then just strip the 'my' part from the ID, but that just seems Yuk!
Below is my click event and where my AJAX event is.
<script type="text/javascript" language="text/javascript">
$(document).ready(function()
{
$(".removeAction").click(function()
{
//AJAX here that needs to know the ID
}
});
</script>
I am sure there is a nice way of doing this?
Thanks. Jake.