Hello. There is a table.

<tr> <td><div class="cart-image"> <img src="/img.jpg" alt="" /> </div> <div class="name">Элемент1<span class="color">Цвет</span> <span class="name-articul">Арт. PM</span> </div> </td> <td class="price">130 руб.</td> <td id="cart-number-617" class="cart-number" rel="6"><div> <span class="minus"></span> <span class="cart-item">1</span> <span class="plus"></span> </div> </td> <td id="cart-summ-617" class="cart-summ" rel="6"><span>130</span> руб.</td> <td id="cart-refuse-617" class="cart-refuse" rel="6"><span>удалить</span> </td> </tr> 

Clicking on <td id="cart-refuse-617" class="cart-refuse" rel="6"><span>удалить</span>
Runs the script

 $("#cart-refuse-" + id + "[rel=" + color + "]").css({"display":"none"}); 

But there was a problem with such rows in the MB table a lot, and <td id="cart-refuse-617" class="cart-refuse" rel="6"><span>удалить</span> this field is repeated - they a lot on the page, so that the script runs only on the topmost element.
The structure of the table cannot be changed.

  • one
    id is a unique identifier for an element and should be. There should not be several elements with the same id on the page - Alex

1 answer 1

Use html5 data- * attributes

 <td data-id="cart-summ-617" class="cart-summ" rel="6"><span>130</span> руб.</td>