换行的区别,简单的问题 <br />是html的格式,被解析为换行\n换行字符。也就是说一个html标签,一个是字符。不是同一层面的东西。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面是.js的文件,3到6行的最后面"<br>\n"和"<br>"有什么区别?谢谢//define the functionsfunction PrintCard(){line1="<b>name: </b>" + this.name + "<br>\n";line2="<b>Address: </b>" + this.address + "<br>\n";line3="<b>Work Phone:</b>" + this.workphone + "<br>\n";line4="<b>Home Phone: </b>" + this.homephone + "<hr>\n";document.write(line1,line2,line3,line4);}function Card(name,address,work,home){ this.name=name; this.address=address; this.workphone=work; this.homephone=home; this.PrintCard=PrintCard; }//Create the objectssue=new Card("Sue Suthers","123 Elm Street","555-1234","555-9876");phred=new Card("Phred Madsen","233 Oak lane","555-2222","555-4444");henry=new Card("Henry Tillman","233 Walnut Circle","555-1299","555-1344");//And print themsue.PrintCard();phred.PrintCard();henry.PrintCard(); line1=" <b>name: </b>" + this.name + " <br>\n"; line2=" <b>Address: </b>" + this.address + " <br>\n"; line3=" <b>Work Phone: </b>" + this.workphone + " <br>\n"; line4=" <b>Home Phone: </b>" + this.homephone + " <hr>\n"; 可以很负责的说,这里的\n没有任何意义。若改成如下:line1=" <b>name: </b>" + this.name + " <br>\n"; line1+=" <b>Address: </b>" + this.address + " <br>\n"; line1+=" <b>Work Phone: </b>" + this.workphone + " <br>\n"; line1+=" <b>Home Phone: </b>" + this.homephone + " <hr>\n"; 这样写还有一点意思,就是在debugger的时候,看line1这个变量中的文本时,可以有换行的效果,这个换行的效果是由\n起作用的。而在页面上的换行是由<br>起作用的OK,放分吧~~~~~ 等高手解答网上的一道关于闭包的代码 js 替换字符串问题 注册页面功能的疑问??? 请教Json数据的问题 jQuery -- load()事件 /* 检测字符串是否为数字 ,且允许为空值时*/这样的表单验证怎么做 IE关闭按钮事件 【急】帮忙看一下!(在线等) 如何判断记录位置? 一个简单的问题,送你分数 换行问题 拖放的效果
//define the functions
function PrintCard(){
line1="<b>name: </b>" + this.name + "<br>\n";
line2="<b>Address: </b>" + this.address + "<br>\n";
line3="<b>Work Phone:</b>" + this.workphone + "<br>\n";
line4="<b>Home Phone: </b>" + this.homephone + "<hr>\n";
document.write(line1,line2,line3,line4);
}
function Card(name,address,work,home){
this.name=name;
this.address=address;
this.workphone=work;
this.homephone=home;
this.PrintCard=PrintCard;
}
//Create the objects
sue=new Card("Sue Suthers","123 Elm Street","555-1234","555-9876");
phred=new Card("Phred Madsen","233 Oak lane","555-2222","555-4444");
henry=new Card("Henry Tillman","233 Walnut Circle","555-1299","555-1344");
//And print them
sue.PrintCard();
phred.PrintCard();
henry.PrintCard();
line2=" <b>Address: </b>" + this.address + " <br>\n";
line3=" <b>Work Phone: </b>" + this.workphone + " <br>\n";
line4=" <b>Home Phone: </b>" + this.homephone + " <hr>\n"; 可以很负责的说,这里的\n没有任何意义。
若改成如下:
line1=" <b>name: </b>" + this.name + " <br>\n";
line1+=" <b>Address: </b>" + this.address + " <br>\n";
line1+=" <b>Work Phone: </b>" + this.workphone + " <br>\n";
line1+=" <b>Home Phone: </b>" + this.homephone + " <hr>\n"; 这样写还有一点意思,就是在debugger的时候,看line1这个变量中的文本时,可以有换行的效果,这个换行的效果是由\n起作用的。而在页面上的换行是由<br>起作用的OK,放分吧~~~~~