javascript - createTextNode not keeping font style -


so right im working on list add stuff dynamically. have code far, javascript

$("#textbox").keypress(function(e) { if(e.keycode == 13)     addtosticky(); });  function addtosticky() {     if(count < 5){               var text = document.getelementbyid("textbox").value;         var node = document.createelement("li");         var textnode = document.createtextnode(text);         node.appendchild(textnode);         document.getelementbyid("list").appendchild(node);         count = count + 1;     }else         hidebox("textbox"); } 

and here html

<a href="#" class="sticky" style="text-decoration: none">     <h2 style="font-size:200%; font-weight:bold; padding-bottom:10px; margin-top: 4px">                  notes      </h2>     <p>                          <ul id="list" style="padding-left: 20px">             <li> <b>hire guy! </b></li>         </ul>         <input type="text" name="input" id="textbox">                    </p> </a> 

and last not least in css make < >, < li > , < h2 > have font-style set custom font. when enter want add list types in custom font when added, @ appendchild, no longer has custom font.

the first element has text wrapped inside bold tag, ones added after don't.

if want make list items bold, best way use css set font-weight property of list item elements:

li {     font-weight : bold; } 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -