Reputation: 179
I learned AngularJS before I learned how to connect vanilla JS to HTML. When I run this code in my browser, the console.logs work, but the number 3 isn't showing up in my first die.
Can you help me fix my code?
JavaScript: var roll = document.getElementById('roll');
function Dice() {
Document.write('1');
}
function printNumber() {
var one = document.getElementById("one");
one.innterHTML = "3";
console.log('printNumber called!');
}
roll.onclick = function() {
printNumber();
console.log('rolled!');
};
HTML:
<div class="row">
<div class="dice" id="one">
</div>
<div class="dice" id="two">
2
</div>
</div>
<div class="row">
<div class="button" id="roll">Roll the dice!</div>
</div>
<script type="text/javascript" src="dice.js"></script>
Upvotes: 0
Views: 61
Reputation: 847
innter should be inner and Document should be document.
function Dice() {
document.write('1');
}
function printNumber() {
var one = document.getElementById("one");
one.innerHTML = "3";
console.log('printNumber called!');
}
roll.onclick = function() {
printNumber();
console.log('rolled!');
};
Upvotes: 1