0

Javascript no added css class

// Css class add hoy na please help me //Code check please //Problem thank solution korean please var name = prompt('your name'); var name2 = ('shorif shuvo'); var names = (name + '<br>'); var password1 = parseInt(prompt("your password")); var password2 = parseInt(prompt('confirm password')); if (password1 === password2) { for (var i = 0; i < 10; i++) { document.write(names); } } else { document.write('Are you bad boy'); } var bg = document.getElementsById("bg"); if (name2 == name) { bg.classList.add("bd"); } /* class not add please help me */

11th Mar 2021, 10:25 AM
SHORIF SHUVO
SHORIF SHUVO - avatar
2 Answers
+ 2
class is added, but document.write open a new document, so css are deleted... you must either assign document.body.innerHTML, or dynamically document.write css (inside <style> tag) : document.body.innerHTML += "appended to body content";
11th Mar 2021, 10:32 AM
visph
visph - avatar
0
CSS CODE body { font-size: 30px; font-weight: 500; } .bg{ background-image: url("../images/img-profile.jpg"); color: white; }
11th Mar 2021, 10:26 AM
SHORIF SHUVO
SHORIF SHUVO - avatar