Convert javascript code to html output?

I can use javascript to display html tags and divs, but I want to put some text in a div.

    this.buildDomModel(this.elements["pans"],
        { tag: "div", className: "panel",
          id: "tabs",
          childs: [
            { tag: "div", id: "page_button",
              className: "box",
              childs: [
                { tag: "div", className: "tab_left" },
                { tag: "div", className: "tab_middle",
                { tag: "div", className: "tab_right" }
              ]},  
]

So how do I add text? I want to:

<div class="tab_title">Sample text</div>

will appear in my html in the div tag with the class name tab_middle.

How do I achieve this?

Also, if I create several of these “tablature titles” with sample text, how do I snap them to the center of the screen.

Many thanks. As you can tell, I am new to javascript. However, I have some basic html knowledge. Thank you for helping someone fight books all day.

+3
source share
1 answer

: { tag: "div", className: "tab_title", innerHtml: "Sample text" }, javascript "html", "innerHtml".

@Edit: divs , css : .tab_title {width: ...; margin: 0 auto;}. , / auto, . , div, .tab_title {text-align: center}.

+1

Source: https://habr.com/ru/post/1756770/


All Articles