John
John

Reputation: 1797

jQuery click through on table row excluding certain cells

I have a massive table and i want to be able to click on the and go to another page. However I dont want to allow the click through on the first and the last . So its everything in between really.

 $(".dataTable td").click(function(){
     window.location.href = "LINK";
});

Cheers

Upvotes: 1

Views: 555

Answers (2)

Arun P Johny
Arun P Johny

Reputation: 388316

$(".dataTable td").not(':first-child, :last-child').on('click',  function(){
     window.location.href = "LINK";
});

Upvotes: 0

SW4
SW4

Reputation: 71140

Use:

$('.dataTable td:not(:first-child, :last-child)').click(function(){
     window.location.href = "LINK";
});

Upvotes: 2

Related Questions