Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-02-2006, 12:42 PM   PM User | #1
Tandem
New to the CF scene

 
Join Date: Feb 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Tandem is an unknown quantity at this point
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!
Tandem is offline   Reply With Quote
Old 03-02-2006, 04:19 PM   PM User | #2
Kravvitz
Senior Coder

 
Join Date: Feb 2006
Location: USA
Posts: 1,013
Thanks: 0
Thanked 0 Times in 0 Posts
Kravvitz is an unknown quantity at this point
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.
Kravvitz is offline   Reply With Quote
Old 03-03-2006, 02:56 PM   PM User | #3
Tandem
New to the CF scene

 
Join Date: Feb 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Tandem is an unknown quantity at this point
But, is there any way to change font style using DOM properties or attributes?
Something like: cell.style.face="Arial"

Thanks
Tandem is offline   Reply With Quote
Old 03-03-2006, 03:36 PM   PM User | #4
Kravvitz
Senior Coder

 
Join Date: Feb 2006
Location: USA
Posts: 1,013
Thanks: 0
Thanked 0 Times in 0 Posts
Kravvitz is an unknown quantity at this point
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.
Kravvitz is offline   Reply With Quote
Old 03-11-2006, 11:20 PM   PM User | #5
Tandem
New to the CF scene

 
Join Date: Feb 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Tandem is an unknown quantity at this point
Thanks A Lot
Tandem is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:25 AM.


Advertisement
Log in to turn off these ads.