ใช้คุณสมบัติ wordBreak ใน JavaScript เพื่อตั้งค่ากฎการขึ้นบรรทัดใหม่สำหรับสคริปต์ที่ไม่ใช่ CJK สคริปต์ CJK ต่อไปนี้คือ: C สำหรับจีน, J สำหรับญี่ปุ่น, K สำหรับเกาหลี
ตัวอย่าง
คุณสามารถลองรันโค้ดต่อไปนี้เพื่อเรียนรู้วิธีนำ wordBreak ไปใช้ −
<!DOCTYPE html> <html> <head> <style> #box { width: 150px; height: 120px; background-color: lightblue; border: 1px solid black; } </style> </head> <body> <button onclick = "display()">Set</button> <div id = "box"> This is Demo Text.This is Demo Text.This is Demo Text.This is Demo Text.This is Demo Text.This is Demo Text. </div> <script> function display() { document.getElementById("box").style.wordBreak = "break-all"; } </script> </body> </html>