Не работают обработчики событий
<!DOCTYPE HTML>
<html> <head> <title>Game of Life</title> <script type="text/javascript" src="javascripts/Game of Life.js"></script> </head> <body> <div> <div> <button id="start">Start</button> <button id="pause">Pause</button> <button>Previous</button> <button>Next</button> <output id="output">null</output> </div> <div> <script type="text/javascript"> new GameOfLife(); </script> </div> </div> </body> </html> // Generated by CoffeeScript 1.7.1 (function() { var GameOfLife; GameOfLife = (function() { GameOfLife.prototype.output = null; GameOfLife.prototype.start = null; GameOfLife.prototype.pause = null; function GameOfLife() { this.output = document.getElementById('output'); this.start = document.getElementById('start'); this.pause = document.getElementById('pause'); this.output.value = "FUCK"; document.getElementById('start').onclick = function() { return this.output.value = "startF"; }; this.pause.onclick = function() { return this.output.value = "pauseF"; }; } return GameOfLife; })(); window.GameOfLife = GameOfLife; }).call(this); |
Если чё, я про
document.getElementById('start').onclick = function() { return this.output.value = "startF"; }; this.pause.onclick = function() { return this.output.value = "pauseF"; }; |
Цитата:
|
V_Pavel_V,
:cray: <!DOCTYPE HTML> <html> <head> <title>Game of Life</title> <script> window.onload = function () { var output = document.getElementById('output'), start = document.getElementById('start'), pause = document.getElementById('pause'); output.innerHTML = "FUCK"; start.onclick = function () { output.innerHTML = "startF"; }; pause.onclick = function () { output.innerHTML = "pauseF"; }; } </script> </head> <body> <div> <div> <button id="start">Start</button> <button id="pause">Pause</button> <button>Previous</button> <button>Next</button> <output id="output">null</output> </div> <div> </div> </div> </body> </html> |
рони,
Спасибо, что обратил внимание на мою проблему. Но мне надо написать приложение на coffeescript, а потом скомпилировать на javascript, если вы вдруг шарите в coffeescript, то может здесь увидите ошибку. class GameOfLife output: null start: null pause: null constructor: -> @output = document.getElementById 'output' @start = document.getElementById 'start' @pause = document.getElementById 'pause' @output.value= "FUCK" document.getElementById('start').onclick= ()-> @output.value = "startF" @pause.onclick= ()-> @output.value = "pauseF" window.GameOfLife = GameOfLife //@output.value= "FUCK" - это строка норм работает, далее нет |
this.output.value = "FUCK"; - в javascript также работает
|
Часовой пояс GMT +3, время: 18:24. |