Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I am doing it wrong in JavaScript

Name: Anonymous 2006-06-12 13:43

Yeah, JS is a scripting language and not a programming language, whatever. Anyway, I've got a page where the script does the following a couple of times:

var i = document.createElement('div');
i.innerHTML = 'some text';
i.class = 'some CSS class';
document.getElementById('element already in the page').appendChild(i);

Name: Anonymous 2006-06-12 13:55

Write yourself a function that does what you want, son. It's called abstraction.

Name: Anonymous 2006-06-12 14:06

>>2

What makes you think you're not looking at the inside of a function?

function dothisonload() {
  for (i to whatever) {gomakeanelement(arguments)};
}

//buncha other functions that act on user input

Name: Anonymous 2006-06-12 14:23

>>1 Since you are using the IE DOM.
Learn how to use i.insertAdjacentHTML() and i.style
Also, pick up the JavaScript pocket reference by O'Reilly so you don't need to ask questions.

Name: Anonymous 2006-06-12 14:54

>>4
use document.createTextNode and i.styleName to get cross-browser compliance

Name: Anonymous 2006-06-12 16:15

.className and put what you want directly into css?
not sure how relevant is what you want
http://www.quirksmode.org/dom/classchange.html

Name: Anonymous 2006-06-12 17:57 (sage)

not a programming language
How so?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List