换行的区别,简单的问题 <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,放分吧~~~~~ 系统登录时多次出现选择浏览器证书框,当选择正确的浏览器证书时点击确定,仍然继续弹出选择证书框口? 百度Web手写输入功能用的什么技术? 如何返回select选中值(在线急等) js限制上传文件类型和大小 encodeURL加密 求购关于浮点数小数位取舍的function! 把指定页面上的text 里面都添加字符 如何绕过管理员权限来在线安装软件? 求教,怎样判断两个字符串在一个数组里面,我现在想问的是下面这个例子的判断条件为正确时,isCurrentUserInWriters 还是为false 新手上路,想请教下一些JavaScript 的问题 换行问题 拖放的效果
//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,放分吧~~~~~