1. 程式人生 > >【Bootstrap】 table表格裡的某一行置頂

【Bootstrap】 table表格裡的某一行置頂

針對bootstrap table:
JS:

//$(this)是置頂的那個按鈕
var $tr = $(this).parent('td').parent('tr');
$('#table tbody').find("tr").first().before(tr);

JQuery:

//$('.top')是置頂的那個按鈕的class
var $top = $(".top");
$top.click(function(){
    var $tr = $(this).parents("tr");
    $tr.fadeOut().fadeIn();
    $("#toptable"
).prepend($tr); });