Created
July 9, 2013 00:58
-
-
Save bessiec/5953803 to your computer and use it in GitHub Desktop.
Hackbright Javascript About Me Exercise: http://icyfenix.github.io/javascript-for-python-developers/exercises/dom.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>About Me</title> | |
</head> | |
<body> | |
<style> | |
.listitem{ | |
color: red; | |
} | |
</style> | |
<h1>About Me</h1> | |
<ul> | |
<li>Nickname: <span id="name"></span> | |
<li>Favorites: <span id="favorites"></span> | |
<li>Hometown: <span id="hometown"></span> | |
</ul> | |
<script> | |
var myname = document.getElementById('name'); | |
myname.innerHTML = "Bessie"; | |
console.log(name); | |
var faves = document.getElementById('favorites'); | |
faves.innerHTML = "<ul><li>burritos<li>cilantro<li>naps<li>speakers</ul>"; | |
var hometown = document.getElementById('hometown'); | |
hometown.innerHTML = "Los Angeles"; | |
var lis = document.getElementsByTagName('li'); | |
for(var i=0; i<lis.length; i++){ | |
lis[i].setAttribute('class','listitem'); | |
} | |
var myimage = document.createElement('img'); | |
myimage.src = 'http://qph.is.quoracdn.net/main-thumb-4691047-200-oyECamHWJalEhAEjl8OHUP2GgVItFH8F.jpeg'; | |
var getstuff = document.getElementsByTagName('body')[0]; | |
getstuff.appendChild(myimage); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment