English 中文(简体)
Same page SubNav on multi pages website
原标题:Same Page SubNav on multiple pages website

i m 试图改变一个子午线中包含的条块的碎块。 页: 1

<ul id="nav">
   <li class="subnav current"><a href="page1.html">Page1</a>
      <ul>
         <li><a href="page1.html#section1a">Page 1 Section A</a></li>
         <li><a href="page1.html#section1b">Page 1 Section B</a></li>
         <li><a href="page1.html#section1c">Page 1 Section C</a></li>
      </ul>
   </li>
   <li class="subnav"><a href="page2.html">Page2</a>
      <ul>
         <li><a href="page2.html#section2a">Page 2 Section A</a></li>
         <li><a href="page2.html#section2b">Page 2 Section B</a></li>
         <li><a href="page2.html#section2c">Page 2 Section C</a></li>
     </ul>
   </li>
<ul>

Each section has a 1060px width, a left float, and all the sections are included in a div container which overflow is hidden. Here is the script i tried :

$(document).ready(function() {
   var P=($(".section").position().left)*-1
   var N=(P/1060)+1
   $("#nav li.current ul li:first-child").find("a").css("color","#e53f33");
   $("#nav li.current ul li:nth-child(N)").click(function(){
      $(this).siblings().find("a").css("color","#777777");
      $(this).find("a").css("color","#e53f33");
   });
});

当我在同一页上停留时,该笔记本可被罚款。 但是,即,当第1页的一米点点击第2页的链接时,即使一点点点点击另一名儿童,也改变了第一胎。 我的错误在哪里?

http://www.theworkingowl.com“rel=“nofollow”http://www.theworkingowl.com

问题回答

对于开端人来说,为什么要把点击事件放在 anchor上? 此外,儿童的态度并不是你想要的。 你们是否考虑采用/取消课程?

$(document).ready(function() {
   // take care of direct hash links...
   var relative_url = window.location.href.substr(window.location.protocol.length+window.location.hostname.length+3);
   $( a[href=" +relative_url+ "] ).addClass( current ).parent().siblings().find( a ).css( color ,  #777 );

   // take care of clicks that stay on this page...
   $( #nav a ).click(function() {
     $(this).parent().addClass( current ).siblings().removeClass( current );
   });
});

之后,你们的国家安全局......

#nav a { color:#777777; }
#nav li.current a { color:#e53f33; }




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签