Hello! There is a table:
<tr class="tablesorter-headerRow" onclick="sortTable();"> <!--<td data-column="0" class="tablesorter-header" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner"><input type = "checkbox" name = "lol"></input><i class="tablesorter-icon tablesorter-icon"></i></div></td>!--> <td data-column="0" class="tablesorter-header" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner">№<i class="tablesorter-icon tablesorter-icon"></i></div></td> <td data-column="1" class="tablesorter-header tablesorter-headerAsc primary" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner">Cмс<i class="tablesorter-icon tablesorter-icon"></i></div></td> <td data-column="2" class="tablesorter-header tablesorter-headerAsc secondary" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner">Номеров<i class="tablesorter-icon tablesorter-icon"></i></div></td> <td data-column="3" class="tablesorter-header tablesorter-headerAsc tertiary" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner">Время создания<i class="tablesorter-icon tablesorter-icon"></i></div></td> <td data-column="4" class="tablesorter-header tablesorter-headerAsc fourtiary" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner">Периодичность<i class="tablesorter-icon tablesorter-icon"></i></div></td> <td data-column="5" class="tablesorter-header tablesorter-headerAsc fivetiary" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner">Имя отправителя<i class="tablesorter-icon tablesorter-icon"></i></div></td> <td data-column="6" class="tablesorter-header tablesorter-headerAsc sixtiary" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner">Сообщение<i class="tablesorter-icon tablesorter-icon"></i></div></td> <td data-column="7" class="tablesorter-header tablesorter-headerAsc seventiary" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner">Начало отправки<i class="tablesorter-icon tablesorter-icon"></i></div></td> <td data-column="8" class="tablesorter-header tablesorter-headerAsc eight" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner">Окончание отправки<i class="tablesorter-icon tablesorter-icon"></i></div></td> <td data-column="9" class="tablesorter-header tablesorter-headerAsc nine" tabindex="0" unselectable="on" style="-webkit-user-select: none;"><div class="tablesorter-header-inner">Действие<i class="tablesorter-icon tablesorter-icon"></i></div></td> </tr> You need to get the data-column attribute of data-column clicked on. I do this:
function sortTable() { var attr = $(this).attr("data-column"); alert(attr); } Displays undefined . What am I doing wrong?