Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (39 sloc) 1.42 KB
<!DOCTYPE html>
<meta charset="utf-8">
<title>Simple DOM example</title>
.highlight {
color: white;
background-color: black;
padding: 10px;
width: 250px;
text-align: center;
<img src="dinosaur.png" alt="A red Tyrannosaurus Rex: A two legged dinosaur standing upright like a human, with small arms, and a large head with lots of sharp teeth.">
<p>Here we will add a link to the <a href="">Mozilla homepage</a></p>
var link = document.querySelector('a');
link.textContent = 'Mozilla Developer Network';
link.href = '';
var sect = document.querySelector('section');
var para = document.createElement('p');
para.textContent = 'We hope you enjoyed the ride.';
var text = document.createTextNode(' — the premier source for web development knowledge.');
var linkPara = document.querySelector('p');
// You could clone link para by doing something like this and inserting the new para instead
// var newPara = linkPara.cloneNode(true);
para.setAttribute('class', 'highlight');
You can’t perform that action at this time.