Я пытаюсь изменить текст с помощью кнопок увеличения и уменьшения. Я не могу понять, почему это не работает. Вот код.Изменить текст при событии нажатия кнопки
<body>
\t <script type="text/javascript">
\t var word = ["Getting lazy", "Shannon", "Letogasm", "fleek"];
\t var explanation = ["Getting lazy is the act of just laying on the ground after being
\t \t \t slammed or a hard fall.Most commonly used amongst skaters, bmx riders, and other extreme
\t \t \t sports.
\t \t \t ", "
\t \t \t The coolest person in the world.
\t \t \t ", "
\t \t \t Word used by Echelon and any other
\t \t \t Jared Leto fan to describe the feeling of(sexual) pleasure/happiness associated with
\t \t \t watching a Jared Leto/30 Second to Mars Music Video or Movie.In other words, a Jared Leto
\t \t \t induced Orgasm.
\t \t \t ", "
\t \t \t on point "];
\t \t \t function inc() {
\t \t \t \t var i = i++;
\t \t \t \t return i;
\t \t \t }
\t \t \t function dec() {
\t \t \t \t var i = i++;
\t \t \t \t return i;
\t \t \t }
\t \t \t var decos = document.getElementById('deco');
\t \t \t decos.addEventListener('click', inc);
\t \t \t var incos = document.getElementById('inco');
\t \t \t incos.addEventListener('click', dec);
\t \t \t document.getElementById('the-h').innerHTML = 'word[i]';
\t \t \t document.getElementById('the-p').innerHTML = 'explanation[i]';
\t </script>
\t <h1 id="the-h"></h1>
\t <p id="the-p"></p>
\t <input type="button" id="deco"><input type="button" id="inco">
</body>
Не работает, когда вы нажимаете кнопку '-' в первый раз или продолжаете нажимать кнопку' + ' – Tushar
Я изменил код. Теперь это работает, не так ли? – verjas
Пс. Я изменил код, чтобы сделать его более чистым. – verjas