Make link in table cell fill the entire row height

后端 未结 10 1029
清酒与你
清酒与你 2020-11-27 03:54

I have a table of data and each cell is a link. I want to allow the user to click anywhere in the table cell and have them follow the link. Sometimes the table cells are m

10条回答
  •  再見小時候
    2020-11-27 04:36

    I will post the same answer here, as I did on my own question.

    Inspired by Jannis M's answer, I did the following:

    $(document).ready(function(){    
        $('table tr').each(function(){
            var $row = $(this);
            var height = $row.height();
            $row.find('a').css('height', height).append(' ');  
        });       
    });
    

    I added a   since empty links (not containing text nodes) can not be styled(?).

    See my updated fiddle.

提交回复
热议问题