I'm trying to create a simple marquee that simply changes in intervals. I am just trying to understand objects in Javascript. Currently, I am receiving the error, object is not a function.
var marquee = {
domElement: jQuery( 'span' ),
titles: [ 'First', 'Second', 'Third', 'Fourth' ],
current: '',
next: 0,
_getCurrent: function(){
this.current = this.domElement.text();
},
_setNext: function(){
this.next = this.titles.indexOf( this.current ) + 1;
},
changeHeading: function(){
this._getCurrent();
this._setNext();
this.domElement.text( this.titles[ this.next ] );
}
};
var marqueeInterval = setInterval( marquee.changeHeading, 700 );
Any help on why I can't get this to work would be greatly appreciated. I am new to Object Oriented Javascript, and am just trying to understand. Thanks!