First I’m brand new to JS but have an idea that object classes are what I should be looking into, yet I can’t find a straightforward tutorial that doesn’t shoot off into arrays,arguments or silly alert boxes! All I’m looking for is something like this:
<head>
<Script Language="JavaScript">
function Class (color, bodypart, item)
Var1 =newClass ('red', 'hand', 'ball')
Var2 =newClass ('green', 'foot, 'bat')
btw I have hundreds of these Vars to write, this is the reason for looking into this method
then put these Vars into some HTML:
('<div><span style="color:'+color+';>'+bodypart+'</span><br/>'+item+'</div><br/>');</script></head>
now in the body I want to call one of the Vars (e.g. Var1) and put it (with the HTML) into a div so it would automatically generate:
<div><span style="color:red;">hand</span><br/>item</div><br/>
My question:what exactly do I put in the head and body to make this happen??
I’m guessing something to do with GetElementById, Classes, etc but I can’t find the right syntax to make a simple example work.
Aaaaany help would be fantastically appreciated for such a noob! (p.s. I have spent the last full 2 days reading tutorials and forum posts but they keep losing me in far more complex things than I can grasp)
You sound like you’re in over your head at this point, and if you plan on doing a lot of javascript, you’re much better off finishing off those tutorials on arrays and such.
Having said that, to help you jump ahead a little, here’s what you need to do:
That function might look something like: