Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problems re-formatting text nodes

    Hello!
    I want to change the font of a text node I've just created using appendChild but doesn't work the ways I've tried. Could you tell me how to do it?

    var table=document.getElementById("table_name");
    tbody = table.appendChild(d.createElement("tbody"));
    var row = tbody.appendChild(d.createElement("tr"));
    var cell =d.createElement('td');
    var txt=document.createTextNode('Hello World!');
    cell.appendChild(txt);
    row.appendChild(cell);

    I want to change the font to: <font size="2" face="Verdana, Arial, Helvetica, sans-serif">

    thanks!

  • #2
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is a bit old, but much of what it says is relevant -- What's wrong with the FONT element?

    Use CSS.
    Adding a touch of style
    Learning CSS
    CSS2 Specification
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #3
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But, is there any way to change font style using DOM properties or attributes?
    Something like: cell.style.face="Arial"

    Thanks

  • #4
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes.
    Code:
    cell.style.fontFamily = 'Verdana, Arial, Helvetica, sans-serif';
    cell.style.fontSize = '.8em';
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #5
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks A Lot


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •