Iterate through and delete empty HTML table rows with jQuery

前端 未结 4 1016
梦如初夏
梦如初夏 2021-01-18 18:50

I am attempting to iterate through a HTML table using jQuery and delete empty rows. The page is driven by ASP.NET and with certain permission, items in the table will be hid

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-18 19:38

    Try this:

    var td = $(this).find('td:empty');
    if ( td.length > 0 ) $(this).remove();
    

    http://api.jquery.com/empty-selector/

    That said, you really want to do this on the server side. It'll look ugly on the client side because you'll have the empty rows messing things up until the document ready event is fired.

提交回复
热议问题