当前位置: 代码迷 >> JavaScript >> jquery 关于生成html的有关问题
  详细解决方案

jquery 关于生成html的有关问题

热度:323   发布时间:2012-04-16 16:20:04.0
jquery 关于生成html的问题
预期的html代码:
HTML code

<table width="94%" height="0" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#97aa9f">
    <tr>
        <th width="11%" align="center" >3333</th>
        <th width="12%" height="27" align="center" >33333</th>
        <th width="13%" align="center" >2222</th>
        <th width="17%" align="center" >rrrrr</th>
        <th width="13%" align="center" >rrrr</th>
        <th width="12%" align="center" >123344</th>
        <th width="9%" align="center" >1111</th>
        <th width="9%" align="center" >111111</th>
        <th width="11%" align="center" >111111</th>
        <div id="html">
            <tr>
                <td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>
                <td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>
                <td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>
                <td align="center" bgcolor="#FFFFFF"><div align="center">fffff</div></td>
                <td align="center" bgcolor="#FFFFFF"><div align="center">fff</div></td>
                <td align="center" bgcolor="#FFFFFF"><div align="center">fff</div></td>
                <td align="center" bgcolor="#FFFFFF"><div align="center">fff</div></td>
                <td align="center" bgcolor="#FFFFFF"><div align="center">ff</div></td>
                <td align="center" bgcolor="#FFFFFF"><div align="center">fff</div></td>
            </tr>
        </div>
    </tr>
</table>


js代码:
HTML code


<script>
var mgs = '<tr><td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>'+
            '<td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>'+
            '<td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>'+
            '<td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>'+
            '<td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>'+
            '<td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>'+
            '<td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>'+
            '<td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td>'+
            '<td align="center" bgcolor="#FFFFFF"><div align="center">ffff</div></td></tr>'
            $(document).ready(function(){
                $("#html").html(mgs);
            })
</script>
<table width="94%" height="0" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#97aa9f">
    <tr>
        <th width="11%" align="center" >3333</th>
        <th width="12%" height="27" align="center" >33333</th>
        <th width="13%" align="center" >2222</th>
        <th width="17%" align="center" >rrrrr</th>
        <th width="13%" align="center" >rrrr</th>
        <th width="12%" align="center" >123344</th>
        <th width="9%" align="center" >1111</th>
        <th width="9%" align="center" >111111</th>
        <th width="11%" align="center" >111111</th>
        <div id="html">

        </div>
    </tr>
</table>
 
  相关解决方案