0

I have multiple tables with the same id and I want to hide a particular table when it is clicked. Please suggest me about how to do it.

Utkarsh Singh
  • 283
  • 2
  • 12

2 Answers2

2

id is unique, you need to use class instead, then you can do:

$('.classOfYourTables').click(function() {
    $(this).hide();
});
Felix
  • 37,892
  • 8
  • 43
  • 55
1

Always use unique ID ,its the best practice,classes are not Unique classTable=> class given to all tables And the id for each table is Unique .

<script>
$(".classTable").click(function() {

    var tblId=$(this).attr("id");
    alert(tblId);
    $("#"+tblId).hide();
});
</script>

on any table User clicks , Get id of the current Table class which is clicked.And hide only those class by taking its ID ,As IDs are unique

Fiddle =>http://jsfiddle.net/c7F7a/

Pratik Joshi
  • 11,485
  • 7
  • 41
  • 73