-1

js code

result

Question: why doesn't it display all the styles I made?

Barmar
  • 741,623
  • 53
  • 500
  • 612
Abdullah Ajmal
  • 367
  • 3
  • 14

1 Answers1

0

document.write erases everything on the page including your styles. You'll have to include your styles with document.write . So you'll probably have to something like

function disptayQuestion(questionIndex) {   
    var q = questions [questionlndex] ;     
    document.write('<link rel="stylesheet" type="text/css" href="yourstyle.css">');
    document.write( (questionlndex + 1) + "." + q.question + "<br>" );
    document.write(q.optionA +  "<br>");
    document.write(q.optionB +  "<br>");
    document.write(q.optionC +  "<br>");
    document.write(q.optionD);  

}
Raymond
  • 396
  • 4
  • 21