Click here to Skip to main content
15,886,095 members
Articles / Web Development / HTML

MiniRacer - Extending W3C DOM Elements using JavaScript (IE)

Rate me:
Please Sign up or sign in to vote.
4.13/5 (5 votes)
16 Feb 20058 min read 83.1K   499   22  
A JavaScript table-based driving game to demonstrate how to extend W3C DOM Elements to add your own functionality.
// SpeedSelector is a wrap around class for the speed select element
// on the web-page. The id of the select element is passed in on construction

function SpeedSelector(id)
{
 this.init(id);
}

SpeedSelector.prototype.init = SpeedSelector_init;
SpeedSelector.prototype.getSpeed = SpeedSelector_getSpeed;

function SpeedSelector_init(id)
{
	this._selectElement = document.getElementById("speedSelect");
}

function SpeedSelector_getSpeed()
{
	return this._selectElement[this._selectElement.selectedIndex].value;
}


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United Kingdom United Kingdom
Teacher: Maths and Computing, Secondary School.

First learnt to program in BASIC on an Amstrad CPC464 and then continued messing around with programs at university and ever since. Doesn't know a huge deal about any of it really but enjoys the challenge and is always keen to learn a new trick!

Comments and Discussions