Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Cách đặt độ rộng viền trái với JavaScript?

Sử dụng borderLeftWidth để đặt độ dày viền bên trái.

Ví dụ

<!DOCTYPE html>
<html>
  <head>
    <style>
      #box { border: thick solid gray; width: 300px; height: 300px; }
    </style>
  </head>
  <body>
    <div id="box">Demo Text</div>
    <br><br>
    <button type="button" onclick="display()">Thay đổi độ rộng viền trái</button>
    <script>
      function display() {
        document.getElementById("box").style.borderLeftWidth = "10px";
      }
    </script>
  </body>
</html>