JavaScript用document.write()輸出換行的示例代碼
當(dāng)我們想用document.write()輸出換行時(shí),可能會(huì)第一時(shí)間想到加'n',但是其實(shí)不能達(dá)到我們的想要效果,只會(huì)得到一個(gè)空格的效果。
正確的方法是使用:</br>
樣例代碼:
<!DOCTYPE html><html><head><meta charset='utf-8'><script>// 使用 n 換行 ---> 錯(cuò)誤的方法document.write('這是第一句話。' + 'n'); // 并不會(huì)換行,只會(huì)得到一個(gè)空格的效果document.write('這是第二句話。');document.write('</br>'); // 正確的換行document.write('</br>');document.write('</br>');// 使用正確的方法 </br> 換行document.write('這是第一句話。。' + '</br>');document.write('這是第二句話。。');</script><title></title></head><body></body></html>
效果截圖:
到此這篇關(guān)于JavaScript用document.write()輸出換行的示例代碼的文章就介紹到這了,更多相關(guān)js document.write()輸出換行內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. java——Byte類/包裝類的使用說(shuō)明2. android studio實(shí)現(xiàn)簡(jiǎn)單的計(jì)算器(無(wú)bug)3. python 讀txt文件,按‘,’分割每行數(shù)據(jù)操作4. python Selenium 庫(kù)的使用技巧5. android 控件同時(shí)監(jiān)聽(tīng)單擊和雙擊實(shí)例6. python+pywinauto+lackey實(shí)現(xiàn)PC端exe自動(dòng)化的示例代碼7. vue使用exif獲取圖片經(jīng)緯度的示例代碼8. python logging.info在終端沒(méi)輸出的解決9. 詳解android adb常見(jiàn)用法10. Python 忽略文件名編碼的方法
