DEV Community

benoah
benoah

Posted on

Rendering

Challenge

  • Take the hard-coded HTML, bring it into index.js and then inject it back into its div with js.
const heroDiv = document.getElementById('hero')

heroDiv.innerHTML = `
    <div class="character-card">
        <h4 class="name"> Wizard </h4>
        <img class="avatar" src="images/wizard.png"/>
        <p class="health">health: <b> 60 </b></p>
        <div class="dice-container"><div class="dice"> 6 </div></div>
    </div>   
`
Enter fullscreen mode Exit fullscreen mode
  • We can also do it this way :
document.getElementById('hero').innerHTML = `
    <div class="character-card">
        <h4 class="name"> Wizard </h4>
        <img class="avatar" src="images/wizard.png"/>
        <p class="health">health: <b> 60 </b></p>
        <div class="dice-container"><div class="dice"> 6 </div></div>
    </div>   
Enter fullscreen mode Exit fullscreen mode

`

Top comments (0)