我正在尝试添加左右箭头键以导航到照片页面。每个照片页面都有如下导航部分。一旦我按下该键,它就会不停地转发到下一页。谁能帮助我。提前致谢。
<div style="margin: 10px auto 0 auto; text-align: center; width: 650px;">
<div class="nav_section" id="navigation">
<ul>
<li> <a href="/photos/view/120"><img src="/photos/square/120-df1dppn7253nge2e929k.jpg"></a> </li>
<li> <a href="/photos/view/118"><img src="/photos/square/118-dmfpm8xtzdg3kb2k85b8.jpg"></a> </li>
<li> <a href="/photos/view/116"><img src="/photos/square/116-kfaga5w36gbhej7g641c.jpg"></a> </li>
... and so on,....
</ul>
</div>
</div>
这是我得到的垃圾脚本:
<script type="text/javascript">
$(document).ready(function() {
$(document).keyup(function(event) {
var key = event.which;
if(key == 37) { // Left arrow key
$('a').trigger('click');
}
if(key == 39) { //Right arrow key
$('a').trigger('click');
}
});
});
</script>