Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将div标签更改为IE7的表格_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 将div标签更改为IE7的表格

Javascript 将div标签更改为IE7的表格,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我已经用display:table创建了一个Div表;但是ie7或ie6不起作用。。我不想用display-table.htc Hack来做这个 我想改变 "<div class='divTable'> into <table class='divTable'>" "<div class='divRow ieclear'> into <tr class='divRow ieclear'>" "<div class='divCell'>

我已经用display:table创建了一个Div表;但是ie7或ie6不起作用。。我不想用display-table.htc Hack来做这个

我想改变

"<div class='divTable'> into <table class='divTable'>" 
"<div class='divRow ieclear'> into <tr class='divRow ieclear'>" 
"<div class='divCell'> into <td class='divCell'>"
jQuery//

$(function () {
    //alert($.browser.version);
    jQuery("#test").find(".divTable").html('<table class="divTable">' + $(".divTable").html() + "</table>").html();
    //or
    $('div').replaceWith(function () {
        return $("<table />", { html: $(this).html() });
    });
});
$(函数(){
//警报($.browser.version);
jQuery(“#test”).find(“.divTable”).html(“”+$(“.divTable”).html()+“”).html();
//或
$('div')。替换为(函数(){
返回$(“”,{html:$(this.html()});
});
});
请建议我或帮助我解决此问题……:)

尝试使用:

position:relative;
display: table-cell /*IE9+ and other browsers*/;
display: block /*IE8 and lower*/;

一个显而易见的问题是,你为什么不用桌子呢?我认为您应该迭代divTable元素的元素子元素以获得行,然后遍历它们的元素子元素以获得单元格,然后遍历它们的子元素以传输内容。递归函数应该非常小。您应该更改所有浏览器的格式。在客户端执行此操作确实是一个坏主意,尤其是在旧浏览器上执行此操作时,因为它们无法承担如此多的DOM操作。尝试在服务器端执行此操作。感谢@tea\u totaler提供的宝贵建议。我知道这不是个好主意。。。但我不能在表中显示…这就是我在这里发布的原因…可能有人对同一问题有更好的解决方案或想法…让我们看看…写两个不同的页面(一个带有div,另一个带有table),当你看到它是ie7,然后重定向到另一个页面:DDo你真的需要与IE6兼容吗?使用IE7,您可以欺骗CSS使div看起来像一个没有任何
display:table/table row/table cell
指令的表。对于像您这样大小固定的列,使用
float:left
浮动所有单元格并向行中添加
clear:left
应该可以做得很好。IE6然而。。。
$(function () {
    //alert($.browser.version);
    jQuery("#test").find(".divTable").html('<table class="divTable">' + $(".divTable").html() + "</table>").html();
    //or
    $('div').replaceWith(function () {
        return $("<table />", { html: $(this).html() });
    });
});
position:relative;
display: table-cell /*IE9+ and other browsers*/;
display: block /*IE8 and lower*/;