How to Use slideDown (or show) function on a table row?

后端 未结 21 2558
清歌不尽
清歌不尽 2020-11-22 09:03

I\'m trying to add a row to a table and have that row slide into view, however the slidedown function seems to be adding a display:block style to the table row which messes

21条回答
  •  难免孤独
    2020-11-22 09:47

    If you need to slide and fade a table row at the same time, try using these:

    jQuery.fn.prepareTableRowForSliding = function() {
        $tr = this;
        $tr.children('td').wrapInner('
    '); return $tr; }; jQuery.fn.slideFadeTableRow = function(speed, easing, callback) { $tr = this; if ($tr.is(':hidden')) { $tr.show().find('td > div').animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback); } else { $tr.find('td > div').animate({opacity: 'toggle', height: 'toggle'}, speed, easing, function(){ $tr.hide(); callback(); }); } return $tr; }; $(document).ready(function(){ $('tr.special').hide().prepareTableRowForSliding(); $('a.toggle').toggle(function(){ $button = $(this); $tr = $button.closest('tr.special'); //this will be specific to your situation $tr.slideFadeTableRow(300, 'swing', function(){ $button.text('Hide table row'); }); }, function(){ $button = $(this); $tr = $button.closest('tr.special'); //this will be specific to your situation $tr.slideFadeTableRow(300, 'swing', function(){ $button.text('Display table row'); }); }); });

提交回复
热议问题