This code iterates over all h2
tags on the page by using the each
function from jQuery.
These tags are selected by using a CSS selector passed as the only argument to the $
function. This function also goes by another name -- jQuery
-- which is what you'd use if you had jQuery.noConflict();
somewhere in your code.
The first argument passed to this each
function is another function itself. This anonymously named function will be executed for each element of the h2
tag collection. The index
argument inside this function is the position of the current iteration. The first element in this collection will have the index
of 0
, the next 1
and the next 2
and so on.
Inside this anonymous function inside the each
, $(this)
selects the current iteration's element, again by using the $
function. When css
is called on $(this)
it sets a specific CSS attribute (the first argument) which is in this case z-index
to the value passed in as the second argument.
I hope this was detailed enough to explain what's going on.