Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery: highlight navig of current anchor tag
    primarykey
    data
    text
    <p>i am getting confused and not able to put things together... </p> <ul> <li>i created a single page website with different sections,</li> <li>i made a sticky nav with jquery.sticky.js,</li> <li>i highlighted the current tab with the help of this : <a href="http://jsfiddle.net/joshnh/YxRqp/" rel="nofollow">http://jsfiddle.net/joshnh/YxRqp/</a>.</li> </ul> <p>But the nav tabs do not change the highlight with scolling when i go from one section to another...</p> <p>I red on internet that Waypoints, a jquery plugin (<a href="http://imakewebthings.com/jquery-waypoints/" rel="nofollow">http://imakewebthings.com/jquery-waypoints/</a>) can help me but it does not work... can someone tell me what js, css and html codes i must add that it works (with Waypoints or without) ? </p> <h1>HTML</h1> <pre><code>&lt;nav id="mainnav"&gt; &lt;div class="container"&gt; &lt;ul class="links"&gt; &lt;li&gt;&lt;a id="homenav" class="scroll" href="#homepage"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="sensnav" class="scroll" href="#parallax1"&gt;Sensuality&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="scennav" class="scroll" href="#parallax2"&gt;Scenes&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="montnav" class="scroll" href="#parallax3"&gt;Montage&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="celenav" class="scroll" href="#parallax4"&gt;Celebrities&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="modenav" class="scroll" href="#parallax5"&gt;Mode&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="portnav" class="scroll" href="#parallax6"&gt;Other Portraits&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="objenav" class="scroll" href="#parallax7"&gt;Objects&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="miscnav" class="scroll" href="#parallax8"&gt;Miscellaneous&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="contnav" class="scroll" href="#contact"&gt;Contact&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a id="morenav" class="scroll" href="#more"&gt;Links &amp; More&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/nav&gt; &lt;section id="parallax1"&gt; &lt;h1&gt;Sensuality&lt;/h1&gt; &lt;/section&gt; </code></pre> <h1>JS for the highlight (in the body part of the index.html)</h1> <pre><code>&lt;script&gt; var main = main = $('#mainnav div ul'); $('.scroll').click(function(event) { event.preventDefault(); var full_url = this.href, parts = full_url.split('#'), trgt = parts[1], target_offset = $('#'+trgt).offset(), target_top = target_offset.top; $('html, body').animate({scrollTop:target_top}, 500); /* Remove active class on any li when an anchor is clicked */ $('#mainnav div ul').children().removeClass(); /* Add active class to clicked anchor's parent li */ $(this).parent().addClass('active'); }); &lt;/script&gt; </code></pre> <h1>CSS</h1> <pre><code>nav { width: 100%; height: 50px; position: relative; z-index: 1000; background: rgba(26,30,39,0.7); opacity: 0; filter: alpha(opacity=0); } nav .container { width: 96%; } .links { height: 50px; display: table-cell; vertical-align: middle; } .links li { height: 50px; display: inline; margin: 0 15px 0 0; padding: 2px; } .links a { font-family: 'Yanone Kaffeesatz', sans-serif; font-size: 20px; color: #ffffff; text-decoration: none; text-transform: uppercase; } .links a:visited { color: #ffffff; } .links a:hover { color: #b0b825; } .links a.current { color: ffd200; } nav#mainnav li.active a { color: #ffd200; } </code></pre> <p>You can see it live here : <a href="http://photography.igorlaszlo.com" rel="nofollow">http://photography.igorlaszlo.com</a></p> <p>Please be precise what i must to do, i am not a professional in javascript... </p> <p>Thanks in advance !</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload