首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

JS中字符串如何换行

2011-12-28 
JS中字符串怎么换行document.getElementById( tb ).value+document.getElementsByTagName( a )[i].href

JS中字符串怎么换行
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
  请高手出手啊!!

[解决办法]
+ "\n "
[解决办法]
var str = 'http://localhost:1043/WebSite2/Default.aspxhttp://localhost:1043/WebSite2/TextLink.aspxhttp://localhost:1043/WebSite2/Default2.aspxhttp://localhost:1043/WebSite2/Default3.aspx ';
var Arr = str.split( "http:// ");
var str1 = ' ';
for (i = 0;i < Arr.length - 1; i++)
{
str1 += 'http:// ' + Arr[i+1] + '\n ';
}
[解决办法]
document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href+ "\n ";

---------------------------------------------
document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href+ " <br> ";

---------------------------------------------

document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href+ "换行!,不换行砸了你!! ";

[解决办法]
document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href+ " <br> ";//页面换行用这个

document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href+ "\n ";//source codes换行用这个

热点排行