Add a “new line” in innerHTML

前端 未结 3 2000
猫巷女王i
猫巷女王i 2020-12-13 19:07

I am trying to create a table with images in first cell and information about the pic in second cell.

I need to add different information in one cell, like that:

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 19:16

    The simplest way is by adding a line break as html

    cellTwo.innerHTML = arr_title[element] + "
    " + arr_tags[element];

    If you want your newlines to be treated literally, you could use the

     tag

    cellTwo.innerHTML = 
        "
    " + arr_title[element] + "\n" + arr_tags[element] + "
    ";

提交回复
热议问题