Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

วิธีสร้างข้อความตัวเล็กด้วย JavaScript

ใช้เมธอด small() ของ String ทำให้ข้อความแสดงขนาดเล็ก เหมือนแท็ก <small>

ตัวอย่าง

<html>
  <head>
    <title>JavaScript String small() Method</title>
  </head>
  <body>
    <script>
      var str = new String("Demo Text");
      document.write(str.small());
      alert(str.small());
    </script>
  </body>
</html>

ผลลัพธ์

<small>Demo Text</small>

⚠️ Legacy method – ไม่แนะนำใช้ ใช้ CSS font-size: smaller; หรือแท็ก <small> ใน HTML โดยตรง