过滤后

时间:2017-02-01 11:13:16

标签: javascript php html sorting html-table

我试图在过滤后对学生进行排序。过滤后,学生按钮类将更改和文本,如下图所示。

enter image description here

我想要的是精选学生的学生必须先进入拒绝学生学生!我怎么能这样做??

PHP-> HTML返回如下:

<tbody>

<tr>
<td><span><img></span><p>Rasmus1 Lerdorf</p><p><b>Hallticket</b> : S28J1</p></td>
<td style="line-height:45px">4</td>
<td style="line-height:45px">9</td>
<td style="line-height:45px">8</td>
<td style="line-height:45px">4.5</td>
<td><span id="stu28" class="btn btn-danger reject-student selection-class">Not Selected</span></td>
<td style="line-height:45px"><input class="overrideStudent" type="text" name="picomment[28]"></td>
</tr>

<tr>
<td><span><img></span><p>Bill Gates</p><p><b>Hallticket</b> : S29J1</p></td>
<td style="line-height:45px">9</td>
<td style="line-height:45px">10</td>
<td style="line-height:45px">8</td>
<td style="line-height:45px">6.1</td>
<td><span id="stu28" class="btn  selection-class btn-success select-student">Selected</span></td>
<td style="line-height:45px"><input class="overrideStudent" type="text" name="picomment[29]"></td>
</tr>

</tbody>

这是选择学生的Javascript代码:

success: function (response) {
    $(".selection-class").addClass('btn-danger reject-student');
    $(".selection-class").removeClass('btn-success select-student');
    $(".selection-class").text('Not Selected');
    $.each(response['students'], function(k, student) {
        $("#stu"+student.student_id).removeClass('btn-danger reject-student');
        $("#stu"+student.student_id).addClass('btn-success select-student');
        $("#stu"+student.student_id).text('Student Selected');
    });
    $("#success_message").show();
    $("#success_message").html(response['message']);

1 个答案:

答案 0 :(得分:0)

你可以append()将“拒绝学生”分类到其父选择器并获得所需的结果。