js页面输出html代码怎么写

1.JAVASCRIPT输出HTML代码<script type="text/javascript">
function aa(){
str="<table border=1><tr><td>11111</td><td>222222</td></tr></table><table border=1><tr><td>33333</td><td>444444</td></tr></table>"
【js页面输出html代码怎么写】document.getElementById("d1").innerHTML =str;
}
</script>
<input type="button" value="http://www.xuexi88.com/zhishi/显示表格" onclick="aa()">
<div id="d1"></div>
2.如何用js脚本输出一段Html代码拿到你的页面元素 , 使用append,appendTo,prepend或prependTo
prepend() 语法:$(selector).prepend(content) 或 $(selector).prepend(function(index,html))
prependTo() 语法:$(content).prependTo(selector)
提示:prepend() 和 prependTo() 方法作用相同 。
差异在于语法:内容和选择器的位置 , 以及 prependTo() 无法使用函数来插入内容 。
append() 方法在被选元素的结尾(仍然在内部)插入指定内容 。
append() 语法:$(selector).append(content)
appendTo() 语法:$(content).appendTo(selector)
3.怎么用JS输入HTML代码JS输入输出HTML代码有2种方式:
1、在需要输出的的位置写JS代码:<script>document.write('需要输出的内容')</script>
比如:
<ul>
<script>document.write('<li><a href="http://www.xuexi88.com/wap2/newsPage/1320">5</a></li><li><a href="http://www.xuexi88.com/wap2/newsPage/1319">4</a></li><li><a href="http://www.xuexi88.com/wap2/newsPage/1318">3</a></li><li><a href="http://www.xuexi88.com/wap2/newsPage/1317">2</a></li><li><a href="http://www.xuexi88.com/wap2/newsPage/1316">1</a></li>');
</script>
</ul>
2、采用js的innerHTML方法:
例子;
<ul id="ul"></ul>
<script>
document.getElementById("ul").innerHTML='<li><a href="http://www.xuexi88.com/wap2/newsPage/1320">5</a></li><li><a href="http://www.xuexi88.com/wap2/newsPage/1319">4</a></li><li><a href="http://www.xuexi88.com/wap2/newsPage/1318">3</a></li><li><a href="http://www.xuexi88.com/wap2/newsPage/1317">2</a></li><li><a href="http://www.xuexi88.com/wap2/newsPage/1316">1</a></li>';
</script>
4.如何用js脚本输出一段Html代码拿到你的页面元素 , 使用append,appendTo,prepend或prependToprepend() 语法:$(selector).prepend(content) 或 $(selector).prepend(function(index,html))prependTo() 语法:$(content).prependTo(selector)提示:prepend() 和 prependTo() 方法作用相同 。
差异在于语法:内容和选择器的位置 , 以及 prependTo() 无法使用函数来插入内容 。append() 方法在被选元素的结尾(仍然在内部)插入指定内容 。
append() 语法:$(selector).append(content)appendTo() 语法:$(content).appendTo(selector) 。
5.javascript输出Html代码的问题<body>
<table width="327" height="176" border="1">
<tr>
<td> </td>
<td> <span id="s_a"></span></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><span id="s_b"></span> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>