Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7524711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:08:22+00:00 2026-05-30T03:08:22+00:00

First I’m brand new to JS but have an idea that object classes are

  • 0

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)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:08:23+00:00Added an answer on May 30, 2026 at 3:08 am

    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:

    • Go to http://www.jquery.com and follow the instructions on how to include jQuery onto your page
    • Write a javascript function that uses jQery to transform a javascript array into your html

    That function might look something like:

    var parts = [
      ['red', 'hand', 'ball'],
      ['green', 'foot', 'ball']
    ];
    
    makePart = function(part){
      var div = $('<div />');
      var span = $('<span />').css({color:part[0]}).text(part[1]);
      div.append( span );
      div.append( $('<br />') );
      div.append( part[2] );
      $('body').append( div ).append( $('<br />') );
    }
    
    // this next line makes all your parts
    $.each( parts, function(index, part) { makePart(part); } );
    
    // while this would only make the first part
    makePart( parts[0] );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, I know how to build a Java application. But I have
I have a jquery bug and I've been looking for hours now, I can't
First, I have a list of QWidget s that I won't know the length
First of all Im new to vb 2010 and so far have enjoyed what
First Im a noob in LINQ ! Then, the thing is that I have
First let me preface this question by saying that I'm fairly new to Javascript.
First of all I have seen that there are many questions about unrecognized selector
First off, I'm not all that familiar with cookies but I know how they
First time user of stackoverflow, but I have followed its development over on Coding
First off, I am using Windows XP. I have multiple hard drives and it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.