function - Cant have class in javascript innerHTML -


<div id="mydiv" class="example">example text.</div> <button onclick="myfunction()">click me</button> 

i have function changes inner html

myfunction() {    document.getelementbyid('mydiv').innerhtml="<ol class="example"><li>example 1</li><li>example 2</li><li>example 3</li></ol>"  } 

and when add class error: unexpected identifier. why this? if have

in javascript , both "" , '' valid strings , happens if want use "" or '' inside string?

var str = "he said me 'hi'"

there no problem, long nested character (" or ') different outer character (' or " respectivly)

so in example :

myfunction() {   document.getelementbyid('mydiv').innerhtml="<ol class='example'><li>example 1</li><li>example 2</li><li>example 3</li></ol>" } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -