读书人

js设置title属性时怎么表示换行符?

发布时间: 2012-02-09 18:22:27 作者: rapoo

js设置title属性时如何表示换行符???
<body>
<a href= "xxxx.aspx " id= "test " title= "aaa
\\naaa "> new </a>
</body>

以上能正确换行

aaa
\\naaa

当用js指定时:
<script>
window.onload=function (){
documnet.getElementById( 'test ').setAttribute( 'title ', 'now
changed ');
}
</script>
</HEAD>
<body>
<a href= "xxxx.aspx " id= "test " title= "aaa
\\naaa "> new </a>
</body>
</HTML>

链接的title变为了:now
changed

也就是说换行关健字
此时没有起作用,请问该如何设置!

3Q

[解决办法]
<script>
window.onload=function (){
document.getElementById( 'test ').setAttribute( 'title ', 'now\nchanged ');
}
</script>
</HEAD>
<body>
<a href= "xxxx.aspx " id= "test " title= "aaa
\\naaa "> new </a>
</body>

读书人网 >JavaScript

热点推荐