Created
October 17, 2021 21:24
-
-
Save SackeyDavid/cf66735d7807615565b6d87c89695137 to your computer and use it in GitHub Desktop.
Add elements dynamically to HTML DOM
This file contains hidden or 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
// parent div | |
var checkboxDiv = document.querySelector('#must-haves'); | |
if(checkboxDiv.childElementCount > 0) { | |
let checkboxDivContents = checkboxDiv.innerHTML; | |
let str = checkboxDivContents + '<table><tbody><tr><td><ion-checkbox class="checkbox" checked="true" style="width: 50vw;--border-radius: .35rem;--background: #EEF0F2;--border-color: #EEF0F2;" color="dark"></ion-checkbox></td><td style="position: relative;top: -.19rem;"><span style="margin-left: calc(-50vw + 2.15rem)">'+ instructionData.instruction + '</span></td></tr></tbody></table>'; | |
checkboxDiv.innerHTML = str; | |
} else { | |
checkboxDiv.innerHTML = this.addCheckbox(instructionData.instruction); | |
} | |
addCheckbox(text: string) { | |
let str = '<table><tbody><tr><td><ion-checkbox class="checkbox" checked="true" style="width: 50vw;--border-radius: .35rem;--background: #EEF0F2;--border-color: #EEF0F2;" color="dark"></ion-checkbox></td><td style="position: relative;top: -.19rem;"><span style="margin-left: calc(-50vw + 2.15rem)">'+ text + '</span></td></tr></tbody></table>'; | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment