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换行用这个