I can use javascript to get html tags and divs to appear but I want to put some text in a div.
this.buildDomModel(this.elements["pans"],
{ tag: "div", class开发者_Python百科Name: "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 to this? I want:
<div class="tab_title">Sample text</div>
to appear in my html within the div tag with classname tab_middle.
How do I achieve this?
Also, if I create several of these "tab-titles" with sample text how do I allign them to the centre of the screen.
Thank so much. As you can tell I am a noice at javascript. I do have some basic html knowledge though. Thanks hope someone can help been struggling through books all day
To add the text: { tag: "div", className: "tab_title", innerHtml: "Sample text" }
, some javascript libraries use just "html" rather than "innerHtml".
@Edit:To center divs to the screen, css needs to be: .tab_title {width: ...; margin: 0 auto;}
. You need to set an explicit width to get the left/right auto
margin to center it. If you just want the text in the divs centered, then .tab_title {text-align: center}
.
精彩评论