0

Javascript Constructors

Where should I put them? I get "Object is not a function", why?

5th Aug 2017, 4:33 PM
Andrés04_ve
Andrés04_ve - avatar
6 Answers
0
Oh, thanks, i missunderstood objects and classes :p
5th Aug 2017, 6:00 PM
Andrés04_ve
Andrés04_ve - avatar
+ 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
5th Aug 2017, 5:19 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 3
whats your code? dont expect us to read your mind
5th Aug 2017, 4:43 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 3
uh.... tab=function(){....}
5th Aug 2017, 5:58 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 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;
5th Aug 2017, 5:17 PM
Andrés04_ve
Andrés04_ve - avatar
+ 1
i try to make a class. how do I do it?
5th Aug 2017, 5:54 PM
Andrés04_ve
Andrés04_ve - avatar