locked
jquery replace <th> with <td> or remove <th> RRS feed

  • Question

  • User-944424728 posted

    Hello, how do I replace <th> with <td> or remove <th>. Right now the grid table find <th> and made it red color. Thanks.

    $('#ctl00_Main_content_ucApplicationQuestions_gridApplicationQuestions').find('th').css( "background-color", "red" );

    });

    Friday, June 14, 2019 3:33 PM

All replies

  • User2103319870 posted

    or remove <th>

    You can use remove method like below

    $('#ctl00_Main_content_ucApplicationQuestions_gridApplicationQuestions').find('th').remove();

    Friday, June 14, 2019 4:47 PM
  • User-2054057000 posted

    aspvbnet

    Hello, how do I replace <th> with <td> or remove <th>. Right now the grid table find <th> and made it red color. Thanks.

    $('#ctl00_Main_content_ucApplicationQuestions_gridApplicationQuestions').find('th').css( "background-color", "red" );

    });

    Try the below jQuery code:

    var th = $('#ctl00_Main_content_ucApplicationQuestions_gridApplicationQuestions').find('th'); //find the th
    var thHtml= $(th).html(); // get the th html
    
    // start building the td and add replace the th & it's content var tdnew= "<td>" + thHtml + "</td>"; $(th).html(tdnew);

    While using this code make sure you know how to use the jQuery Find method.

    Sunday, June 16, 2019 3:16 AM