document.getElementsByTagName("p")
[ <p...]
document.getElementById("pierwszy")
[ <p... ]
document.getElementsByName("p")
[]
document.getElementsByName("pierwszy")
[]
document.body.innerHTML = "<h1>Heading 1</h1>"
h = document.createElement("h1")
h_text = document.createTextNode("Heading 1")
h.appendChild(h_text)
document.body.appendChild(h)
minimal2.html
window.onload = function() {
h = document.createElement("h1")
h_text = document.createTextNode("Heading 1")
h.appendChild(h_text)
document.body.appendChild(h)
}
window.onload = function() {
h = document.createElement("button")
h_text = document.createTextNode("Click!")
h.appendChild(h_text)
h.addEventListener('click',function(){
alert(h.firstChild.data);
h.firstChild.data = 'Clack!'
}, false);
document.body.appendChild(h)
}
Rozgrzewka:
#content