最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Add HTML tag in javascript - Stack Overflow

programmeradmin1浏览0评论

I got an Javascript code like this:

divElement.appendChild(document.createTextNode("Optie " + inputNumber + ": "));

Now I would like to put "Optie " and ": " in h7 tags.

How can i do this?

I got an Javascript code like this:

divElement.appendChild(document.createTextNode("Optie " + inputNumber + ": "));

Now I would like to put "Optie " and ": " in h7 tags.

How can i do this?

Share Improve this question edited Oct 19, 2011 at 13:19 Augus asked Oct 19, 2011 at 13:12 AugusAugus 4931 gold badge8 silver badges25 bronze badges 6
  • @BalaR - I guess so, his title says Javascript – Duniyadnd Commented Oct 19, 2011 at 13:16
  • Yea i do :) Sorry for the confusion :). – Augus Commented Oct 19, 2011 at 13:18
  • h7 tags?! the range is from 1 to 5! – daveoncode Commented Oct 19, 2011 at 13:22
  • What are h7 tags? You must be new to HTML. @daveoncode, tags range from 1-6 – zzzzBov Commented Oct 19, 2011 at 13:22
  • 1 ops! falled in the same error :P 1 to 6... anyway there is not h7 tag :P – daveoncode Commented Oct 19, 2011 at 13:26
 |  Show 1 more ment

2 Answers 2

Reset to default 5

there is no "h7". Max is H6

newHeadline = document.createNode( 'h6' ); newHeadline.createTextNode("Optie " + inputNumber + ": ") divElement.appendChild( newHeadline );

Sorry, the right code:

newHeadline = document.createElement( 'h6' );
text = document.createTextNode("Optie " + "ddd"+ ": ")
divElement.appendChild( newHeadline.appendChild( text ) );
var myHeader = document.createElement("h5");
myHeader.innerHTML = "Optie " + inputNumber + ":";
myHeader; // => <h5>Optie 123:</h5>
发布评论

评论列表(0)

  1. 暂无评论