Hướng dẫn dùng js createelement trong PHP
Ngày đăng:
03/09/2022
Trả lời:
0
Lượt xem:
137
Show Trong một tài liệu HTML, phương thức Cú phápvar element = document.createElement(tagName);
Là
thẻ HTML mà bạn muốn tạo mới. Không sử dụng tên đủ điều kiện (như “ Giá trị trả về Trả về Ví dụHTML
JavaScript document.body.onload = addElement; function addElement () { // create a new div element var newDiv = document.createElement("div"); // and give it some content var newContent = document.createTextNode("Hi there and greetings!"); // add the text node to the newly created div newDiv.appendChild(newContent); // add the newly created element and its content into the DOM var currentDiv = document.getElementById("div1"); document.body.insertBefore(newDiv, currentDiv); } Kết quả Tính tương thích của trình duyệt webTrình duyệt trên máy tính
Trình duyệt trên thiết bị di động
Tham khảo:
|