Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Iam getting console output as [object HTMLLIElement]

function render()
    {
       value="";
       b="";

       for(i=0;i<link.length;i++)
        {
          value=document.createElement("li");
          value.innerText=link[i];
          b+=value;
        }  
       console.log(b);
    }

I want the output to be li … li li….li but my output is [object HTMLLIElement] can anyone guide?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

when you append value to the variable b

value is DOM object

so if you want the string for HTML you can use outerHTML property

function render()
    {
       value="";
       b="";

       for(i=0;i<link.length;i++)
        {
          value=document.createElement("li");
          value.innerText=link[i];
          b+=value.outerHTML;
        }  
       console.log(b);
    }
1 comments

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading