...

View Full Version : Assign Style and class



TheOne(AKA:T1)
02-07-2006, 04:59 PM
Ok, I've got this pice of code:

var ourDiv=document.getElementById('cretor);
var t=document.createElement('table');
var tb=document.createElement('tbody');
t.style.border='8px groove blue';

var tr=document.createElement('tr');
var td=document.createElement('td');
Then I append and everything...
My question:
I want to assign a class and a style,
the class named "asdf" and in the style, a "border-top-width of 35px" and a "border-top-style of outset, how do I put them :confused:
THX
EDIT:
And if I make a button and whant to assigne it an event, let's say onClick :confused:

Kor
02-07-2006, 06:20 PM
element.className='myclass';
element.style['attribute']='somevalue'

TheOne(AKA:T1)
02-07-2006, 06:22 PM
THX men
EDIT:
Whyyyyyyyyy!!!!!
The class thing worked, but when I tryed this:
t.style['border-top-width']='35px';
it doesn't works!!!!!!
("t" is my element)

liorean
02-07-2006, 08:11 PM
It doesn't work because the languages allow different characters and sometimes a term used in one language is a reserved word in another.

CSS: "border-top-color" --> JS: "borderTopColor"
HTML: "http-equiv" --> JS: "httpEquiv"
CSS: "float" --> JS: "cssFloat"
HTML: "for" --> JS: "htmlFor"
HTML&CSS: "class" --> JS: "className"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum