All delete links in below grid are simple links with class name "removeItem".
We will loop through every items which have class "removeItem" assigned.
And we will add click event to all of them, which will first confirm deletion and
on approval it will delete parent row of that delete link.
Index
|
Item Name
|
Price
|
Delete
|
1
|
Cheese cubes
|
$5.00
|
Delete
|
2
|
Wheat breads
|
$6.00
|
Delete
|
3
|
Lorem epsum!!
|
$7.00
|
Delete
|
4
|
Doller sit amet!!
|
$9.00
|
Delete
|
5
|
test test!!
|
$10.00
|
Delete
|
Code:
$(document).ready(function()
{
$(".removeItem").each(function()
{
$(this).bind("click",function()
{
if(confirm("Are
you sure you wish to delete this item?"))
{
$(this).parent().parent().remove();
}
});
});
});