document.getElementById() example
RUN
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <body> <h1>Học lập trình miễn phí tại freetuts.net</h1> <p id="result">Đây là thẻ có id="result"</p> <button onclick="myFunction()">Xem kết quả</button> <script> function myFunction(){ document.getElementById("result").style.color = "red"; document.getElementById("result").style.fontSize = "20px"; document.getElementById("result").style.fontWeight = "bold"; } </script> </body> </html>
PHÓNG TO