document.getElementById('tb').value+=document.getElementsByTagName("a")[i].href; 这是JS代码
运行结果:
http://localhost:1043/WebSite2/Default.aspxhttp://localhost:1043/WebSite2/TextLink.aspxhttp://localhost:1043/WebSite2/Default2.aspxhttp://localhost:1043/WebSite2/Default3.aspx
我需要的结果为:
http://localhost:1043/WebSite2/Default.aspx
http://localhost:1043/WebSite2/TextLink.aspx
http://localhost:1043/WebSite2/Default2.aspx
http://localhost:1043/WebSite2/Default3.aspx
高手请出手!!
运行结果:
http://localhost:1043/WebSite2/Default.aspxhttp://localhost:1043/WebSite2/TextLink.aspxhttp://localhost:1043/WebSite2/Default2.aspxhttp://localhost:1043/WebSite2/Default3.aspx
我需要的结果为:
http://localhost:1043/WebSite2/Default.aspx
http://localhost:1043/WebSite2/TextLink.aspx
http://localhost:1043/WebSite2/Default2.aspx
http://localhost:1043/WebSite2/Default3.aspx
高手请出手!!
如果它是个 会 过滤掉 html 标签的东西 则<br> 会无效
或者 你最终是用 alert 的话 也没效果 那么这时候 你应该使用 /n 来代替 <br>
lux 机器 \b\n
var array = document.getElementById( 'tb ').value.sclips("|");
array[0]
array[1]
array[2]
...
var array = document.getElementById( 'tb ').value.split("|");
array[0]
array[1]
array[2]
...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档 </title>
</head>
<body> <textarea rows="10" cols="100" id="td"></textarea>
<a href="http://localhost:1043/WebSite2/Default.aspx"></a>
<a href="http://localhost:1043/WebSite2/TextLink.aspx"></a>
<a href="http://localhost:1043/WebSite2/Default.aspx"></a>
<a href="http://localhost:1043/WebSite2/TextLink.aspx"></a>
<a href="http://localhost:1043/WebSite2/Default.aspx"></a>
<a href="http://localhost:1043/WebSite2/TextLink.aspx"></a>
<script>
var Arr = document.getElementsByTagName("a");for(var i=0;i<Arr.length;i++)
{
document.getElementById('td').value+=Arr[i].href+"\r";
}
</script>
</body>
</html>
var array = document.getElementById( 'tb ').value.split("|");
array[0]
array[1]
array[2]
...........
{
document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href;
document.write("<br>");
}
楼下的看看我这么写可以么?length的值可以自己指定,也就是td的数量.
我也是初学者.谢谢~
不对请指正!!!