There is a document in which there is a table:
<table> <tr> <th>county</th> <th>city</th> <td><div class="rem">delete</div></td> </tr> <tr> <td>russia</td> <td>moscow</td> <td><div class="rem">delete</div></td> </tr> <tr> <td>usa</td> <td>washington</td> <td><div class="rem">delete</div></td> </tr> <tr> <td>australia</td> <td>sidney</td> <td><div class="rem">delete</div></td> </tr> </table> There is code that works when placed in the console, but when added to .html or loadable .js, it refuses to work, jQuery is connected, everything else works, but this piece does not, although it checked the logic through the console. everything works fine, here's the code:
$(document).ready(function(){ $('.rem').each(function(){ $(this).click(function(){ alert($(this).parents('td').siblings('td:first').text()); }); }); }); alert should display the name of the country .. Help me figure it out, thanks)