mrblah
mrblah

Reputation: 103697

Please explain what this jquery code is doing

Html looks like:

<div class="ticker">
                    <div class="news-heading">Latest News:</div>
                    <span class="active_ticker"><a href="#"> 1] Lorem ipsum dolor sit amet, consectetur adipiscing elit.</a></span>
                    <span><a href="#">2] Mauris semper mi eget libero venenatis mattis.</a></span>
                    <span><a href="#">3] Etiam sit amet enim ante, pulvinar porta sem.</a></span>
                    <span><a href="#">4] Fusce sit amet felis at felis posuere tristique id eu nisi.</a></span>
                    <span><a href="#">5] Integer et eros augue, at cursus turpis.</a></span>
                    <span><a href="#">6] Proin id diam dolor, vitae gravida est.</a></span>

                    </div>


 var $tickeritem = jQuery(".ticker span");
 $new_ticker_item = $tickeritem.filter(":eq(" + i + ")");

What is :eq(" + i+ ") doing?

Upvotes: -1

Views: 103

Answers (4)

Ed Schembor
Ed Schembor

Reputation: 8560

This will set the $new___ticker_item variable to point to the DOM element which is the first span tag within the i-th DOM element with a class of "ticker"

Upvotes: 1

Kelsey
Kelsey

Reputation: 47766

He is grabbing a specific span within .ticker for the index of i.

Upvotes: 0

Stefan Kendall
Stefan Kendall

Reputation: 67892

It's filtering to the appropriate index, mapped to i.

http://docs.jquery.com/Selectors/eq#index

Upvotes: 1

stefita
stefita

Reputation: 1793

jQuery Documentation:

:eq(index) Returns: Array Matches a single element by its index.

Upvotes: 2

Related Questions