var Car = function (x,y) {
this.x = x
this.y = y
}
Car.prototype.draw = function () {
var carHtml = '<img src = "http://nostarch.com/images/car.png">'
this.carElement = $(carHtml)
this.carElement.css({
position:"absolute",
left:this.x,
top:this.y
})
$("body").append(this.carElement)
}
Car.prototype.moveRight = function () {
this.x += 10
this.carElement.css({
left:this.x,
top:this.y
})
}
var tesla = new Car(0,100)
tesla.draw()
var timer = setInterval(tesla.moveRight,30)
Ошибка script.js:19 Uncaught TypeError: Cannot read property 'css' of undefined at Car.moveRight
Почему не работает код?