У меня есть таблица со столбцом состояния, в которой отображается значок воспроизведения / паузы материала в зависимости от состояния. У каждой строки свой идентификатор, моя проблема в том, что я не могу сделать так, чтобы значок переключался по щелчку, если я не использую идентификатор непосредственно в коде, и это не решит мою проблему. Я хочу, чтобы код обрабатывал разные идентификаторы. Я попробовал this.id, он работает с alert (), но в коде это не так.
Что я делаю не так?
HTML
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>satatus</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td ><i id="status-1" aria-hidden="true" medium="" class="v-icon notranslate material-icons theme--light">pause_circle_outline</i></td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td><i id="status-2" aria-hidden="true" medium="" class="v-icon notranslate material-icons theme--light">play_circle_outline</i></td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
</table>
JS
$(document).ready(function(){
$("i").click(function() {
//alert($(this).attr("id"));
$(this).attr("id").click(function(){
//$("#status-1").click(function(){
$(this).text($(this).text() == 'play_circle_outline' ? 'pause_circle_outline' : 'play_circle_outline');
});
});
});