Hướng dẫn how do you display text as variable in html? - làm cách nào để bạn hiển thị văn bản dưới dạng biến trong html?

Sử dụng Document.GetEuityById hoặc Document.Write [] để hiển thị văn bản biến trong HTML. Nếu bạn sẽ hiển thị giá trị biến thành một phần tử cụ thể, hãy sử dụng getEuityById. document.getElementById or document.write[] to display variable text in HTML. If you wan to show variable value into a particular element use getElementById.

Mã ví dụ đơn giản hiển thị giá trị biến thành thẻ H2.




  
    function myFunction[] {
      var number = "Hello 123";
      document.getElementById["myText"].innerHTML = number;
    }
  




  

Bài Viết Liên Quan

Chủ Đề