【发布时间】:2015-10-14 18:11:27
【问题描述】:
我正在尝试通过按钮递增和递减来更改文本。我似乎无法找出为什么它不起作用。这是代码。
<body>
<script type="text/javascript">
var word = ["Getting lazy", "Shannon", "Letogasm", "fleek"];
var explanation = ["Getting lazy is the act of just laying on the ground after being
slammed or a hard fall.Most commonly used amongst skaters, bmx riders, and other extreme
sports.
", "
The coolest person in the world.
", "
Word used by Echelon and any other
Jared Leto fan to describe the feeling of(sexual) pleasure / happiness associated with
watching a Jared Leto / 30 Second to Mars Music Video or Movie.In other words, a Jared Leto
induced Orgasm.
", "
on point "];
function inc() {
var i = i++;
return i;
}
function dec() {
var i = i++;
return i;
}
var decos = document.getElementById('deco');
decos.addEventListener('click', inc);
var incos = document.getElementById('inco');
incos.addEventListener('click', dec);
document.getElementById('the-h').innerHTML = 'word[i]';
document.getElementById('the-p').innerHTML = 'explanation[i]';
</script>
<h1 id="the-h"></h1>
<p id="the-p"></p>
<input type="button" id="deco"><input type="button" id="inco">
</body>
【问题讨论】:
标签: javascript arrays text click innerhtml