JavaScript Why cannot apply style using CSS class in JS function? word cannot apply style,cannot apply paragraph style

In this code the function sayHi() doesn't write text with style. Why? How do I apply CSS class to a document.write in a function?

.class1 {
  color: red;
  font-size: 400%;
}
<script language="javascript" type="text/javascript">
  document.write("<h1 class=class1>Hello World</h1>");

  function sayHi() {
    document.write("<h1 class=class1>Goodbye!</h1>");
  }
</script>

<button onclick="sayHi()">Click me</button>
Answer:1

I am writing tests for a React app using Jest and Enzyme. Enzyme 3.x introduced Adapters to provide compatibility across different versions of React. The installation documentation gives examples how ...

I am writing tests for a React app using Jest and Enzyme. Enzyme 3.x introduced Adapters to provide compatibility across different versions of React. The installation documentation gives examples how ...

  1. configure enzyme adapter
  2. configure enzyme adapter jest
  3. enzyme.configure( adapter new enzyme adapter() )
  4. jest configure enzyme adapter
  5. enzyme.configure( adapter new adapter() )
  6. enzyme-adapter-react-16 configure

In PHP , I've used traits before which is a nice way of separating out reusable code & generally making things more readable. Here is a specific Example: ( trait and class can be in separate ...

In PHP , I've used traits before which is a nice way of separating out reusable code & generally making things more readable. Here is a specific Example: ( trait and class can be in separate ...

I'm stuck with this problem for 3 days now... Someone please help me. Challenge 5 Construct a function intersection that compares input arrays and returns a new array with elements found in all ...

I'm stuck with this problem for 3 days now... Someone please help me. Challenge 5 Construct a function intersection that compares input arrays and returns a new array with elements found in all ...

  1. javascript compare input value
  2. javascript compare input date
  3. javascript compare input string
  4. javascript compare input text
  5. javascript compare two input values
  6. javascript compare two input fields
  7. javascript compare user input
  8. javascript compare 2 input fields
  9. javascript compare user input string
  10. javascript compare two dates input
  11. compare input javascript
  12. javascript compare 2 input
  13. javascript compare two input

I want to develop a browser extension for google chrome and for firefox, which will have shared code. Is there a way, that both extensions (the firefox version and the chrome version) will use the ...

I want to develop a browser extension for google chrome and for firefox, which will have shared code. Is there a way, that both extensions (the firefox version and the chrome version) will use the ...