0
Javascript Constructors
Where should I put them? I get "Object is not a function", why?
6 Answers
0
Oh, thanks, i missunderstood objects and classes :p
+ 4
why do u have same names for that
it should be new tab()
idk what ur trying to achieve but tab refers to the object u declared
+ 3
whats your code? dont expect us to read your mind
+ 3
uh....
tab=function(){....}
+ 2
var tabs = 0;
var tab = {
pos: 0,
text: "",
id: "tab",
color: "#"
};
function tab(){
this.text = prompt('Name:');
this.pos = ++tabs;
this.id += tabs;
this.color += prompt('Tab Color:');
var t = document.createElement('span');
t.innerHTML = this.text;
t.style.left = 10*this.pos+"px";
t.id = this.id += tabs;
document.body.appendChild(t);
}
var x = new tab;
+ 1
i try to make a class.
how do I do it?