- Add to table
Ref: http://stackoverflow.com/questions/23291138/add-thead-and-insert-first-tr-from-tbody-for-parent-table-only
$("document").ready( function() {
$('table').each(function(){
$(this).prepend('')
$(this).find('thead').append($(this).find("tr:eq(0)"));
})});
Ans. 2: append & appendTo
Ref: http://stackoverflow.com/questions/12781886/jquery-add-thead-and-add-tbody
var myTable = jQuery("#myTable");
var thead = myTable.find("thead");
var thRows = myTable.find("tr:has(th)");
if (thead.length===0){ //if there is no thead element, add one.
thead = jQuery("").appendTo(myTable);
}
var copy = thRows.clone(true).appendTo("thead");
thRows.remove();
Ans. 1: REGEX
Ref: http://stackoverflow.com/questions/4374595/how-to-replace-all-tr-tags-with-th-tags
$('#tableId').html($('#tableId').html().replace(/tr/gi, 'th'));
Ans 2: wrapInner & unwrap
Ref: http://stackoverflow.com/questions/18641694/replace-th-with-td-for-specific-span
var $span = $('#ViewPayment_LblPayment');
$span.find('th').wrapInner('').contents().unwrap();
$span.find('tbody').contents().unwrap();
No comments:
Post a Comment