简体   繁体   English

上下滚动页面JavaScript导航

[英]Up and Down scroll page JavaScript navigation

I have up and down arrows on the right hand side of each section where if you click them it scrolls either up or down sections. 我在每个部分的右侧都有向上和向下的箭头,如果您单击它们,它会向上或向下滚动。

<div class="next_section"><a id="after_contact"><img src="<?php echo get_stylesheet_directory_uri() ?>/img/arrow_top.png" width="73" height="36" alt="Prev Section"></a></div> 
<div class="next_section"><a id="after_work5"><img src="<?php echo get_stylesheet_directory_uri() ?>/img/arrow_next.png" width="73" height="36" alt="Next Section"></a></div>

Problem is, not all of the arrows are working to scroll up and down the page. 问题是,并不是所有的箭头都可以在页面上上下滚动。 Some work, some don't. 有些工作,有些没有。 I have made the on each correct to my knowledge with it being an area above or below but if you click on some arrows, it won't do anything. 据我所知,每一个都是正确的,因为它是在上方或下方的区域,但是如果您单击一些箭头,它将无法执行任何操作。

Any one know what is going wrong? 有人知道出了什么问题吗?

URL: http://www.londonadvertising.com/2011 Pastie link: http://pastie.org/2913679 网址: http : //www.londonadvertising.com/2011粘贴链接: http ://pastie.org/2913679

Many Thanks 非常感谢

The problem with the page navigation is that not all the < a > tag ids are unique. 页面导航的问题在于,并非所有<a>标记ID都是唯一的。

The JavaScript is only finding the first the element with a particular ID and only that one will work. JavaScript仅在第一个找到具有特定ID的元素时才会起作用。 All others with the name ID after that will not do anything. 此后具有名称ID的所有其他对象将无任何作用。

If you check, the only arrows that work are the first occurrences of a particular ID. 如果选中,唯一起作用的箭头是特定ID的首次出现。

Ensure that all < a > tags under a div will class 'next_section' have a unique ID 确保div下的所有<a>标记将使类'next_section'具有唯一的ID

<div class="next_section first">
 <a id="after_work1"> <!-- <<<< ID must be unique -->
   <img src="something.jpg" alt="Next Section">
 </a>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM