I have a TABLE structure that i want to convert its element to DIV using jQuery Function HTML EXAMPLE:
Solution 1:
You can use the following:
$("#me").click(function(){
var innerhtml = $("table tr td").html();
var innerhtml = innerhtml.replace(/table/g, "div");
var innerhtml = innerhtml.replace(/tbody/g, "div");
var innerhtml = innerhtml.replace(/tr/g, "div");
var innerhtml = innerhtml.replace(/td/g, "div");
$("table tr td").html(innerhtml);
});
It grabs the HTML from inside your table and replaces all instances of "table", "tbody", "tr", and "td" with "div".
Working example here
|
Post a Comment for "Change All TABLE Elements To DIV Inside The TD Tag Only JQuery"