Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

innerHTML to execute multiple lines

Iam using innerHTML in script part of my HTML file.

    document.getElementById("id1").innerHTML="<font size=4 color=blue><b>Process</b></font><br>"

If it fites in single line ,it is working great, but I want to place multiple lines of HTML code in innerHTML , Is it possible ?

    document.getElementById("demo").innerHTML = "

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    CPU Information
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    No of Cores:
    1
    Speed of each core in Mhz:
    cpu MHz     : 2399.318
    model name  : Intel(R) Xeon(R) CPU           E5645  @ 2.40GHz
    CPU Load:
    0.1
    Top CPU using process/application
    -------------------------------------
    PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
    1 root      15   0 10364  680  576 S  0.0  0.0   0:05.46 init               
    ";
like image 874
Ravi Kishore Avatar asked May 10 '15 07:05

Ravi Kishore


1 Answers

Use ` (backtick) instead of ' or ", it will do the job.

document.getElementById("demo").innerHTML = `

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CPU Information
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
No of Cores:
1
Speed of each core in Mhz:
cpu MHz     : 2399.318
model name  : Intel(R) Xeon(R) CPU           E5645  @ 2.40GHz
CPU Load:
0.1
Top CPU using process/application
-------------------------------------
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
1 root      15   0 10364  680  576 S  0.0  0.0   0:05.46 init               
`;
like image 109
Malachi Waisman Avatar answered Oct 04 '22 02:10

Malachi Waisman