Note that there are some explanatory texts on larger screens.

plurals
  1. POIf in viewport; change border color
    text
    copied!<p>I have different divs and a menuebar which constis out of LI-elements.</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;a href="#first" id="nav1" title="Next Section"&gt;FIRST&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#second" id="nav2" title="Next Section"&gt;SECOND&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#third" id="nav3" title="Next Section"&gt;THIRD&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#fourth" id="nav4" title="Next Section"&gt;FOURTH&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>The names of the div are #first to #fourth.</p> <p>If one of the DIVs (or more) is/ are in the viewport I want to change the color of the bottom-border for the li-element which links to this DIV.</p> <p>For example: If DIV #third is in viewport the third LI-element (#nav3) should change its bottom-border to green. If it leaves the viewport it should change to white again.</p> <ul> <li>Just for the time the DIV is in the viewport. As soon it leaves the viewport I want to undo the color change.</li> </ul> <p>I tried it with jQuery Viewport: <a href="http://www.appelsiini.net/projects/viewport" rel="nofollow">http://www.appelsiini.net/projects/viewport</a></p> <p>My problem is that I can't figure out how to use this selector - I know it's basic stuff but I really can't figure it out.</p> <pre><code>$("#third:in-viewport").each(function() { $("#nav1, #nav2, #nav4").animate({ borderBottomColor: '#fff' },800); $("#nav3").animate({ borderBottomColor: 'green' },800); }); </code></pre> <p>Would be awesome if somebody could help me with this. Thanks a lot!</p>
 

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