How to Create HTML table with fixed header but dynamic column

后端 未结 2 1205
小鲜肉
小鲜肉 2021-01-29 11:51

I have two HTML buttons, one named 3days and other named week. Based on the click of any of these buttons I need to create a dynamic table with Fixed Headers but dynamic column.

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-29 12:25

    Updated Code:

       $("table").hide();
    $("#3").click(function(){
        $("table").show();
        $("th:gt(2)").hide();  
        $("td:gt(2)").hide();  
    });
    
    $("#7").click(function(){
         $("table").show();
        $("th:lt(7)").show();  
        $("td:lt(7)").show();  
    });
    

    Demo: http://jsfiddle.net/hsakapandit/3kUjR/2/

提交回复
热议问题