Atomix
08-20-2010, 08:42 AM
Hello, can you tell me why this code gives me undefined error?
You can see the code in action here:
open this link
http://www.w3schools.com/cn/html/tryit.asp?filename=tryhtml_basic
and paste this code on the left side of the webpage, then press 'edit and click me'
heres the full code:
<html><head><title>eink</title></head>
<body onload="aaa()">
<script type="text/javascript">
function aaa() {
var word2 = document.getElementById('word'),
letters = word2.innerHTML.split(''),
spanified;
for (var k = 0, j = letters.length; k < j; k++) {
spanified += '<span class="style101">' + letters[k] + '</span>';
}
word2.innerHTML = spanified;
}
</script>
<style type="text/css">
.style101
{
background-color: #FF0000;
}
</style>
<h1 id="word">HOUSE</h1>
</body>
</html>
Here is a picture, of how it looks:
http://i33.tinypic.com/nvnk9j.jpg
You can see the code in action here:
open this link
http://www.w3schools.com/cn/html/tryit.asp?filename=tryhtml_basic
and paste this code on the left side of the webpage, then press 'edit and click me'
heres the full code:
<html><head><title>eink</title></head>
<body onload="aaa()">
<script type="text/javascript">
function aaa() {
var word2 = document.getElementById('word'),
letters = word2.innerHTML.split(''),
spanified;
for (var k = 0, j = letters.length; k < j; k++) {
spanified += '<span class="style101">' + letters[k] + '</span>';
}
word2.innerHTML = spanified;
}
</script>
<style type="text/css">
.style101
{
background-color: #FF0000;
}
</style>
<h1 id="word">HOUSE</h1>
</body>
</html>
Here is a picture, of how it looks:
http://i33.tinypic.com/nvnk9j.jpg