Your specific questions:
var featureIconHolder = $(".feature-icon-holder", "#features-links-holder");
Here’s the documentation link for this: http://api.jquery.com/jQuery/#jQuery1
The two arguments here are selector and context. What this does is find all elements of class feature-icon-holder
that are descendents of the element with ID features-links-holder
. This constructs an array-like object that contains 0+ elements depending on how many matched.
what is
$(this).data("id")
Inside the click handler, this
is the element that has been clicked. So $(this)
is a jQuery object for that element, and .data
reads or stores values against an element. It’s then used to construct another selector by concatenating strings.
This changes the displayed ‘feature’ based on the icon clicked. What it does:
- Find all elements with class
feature-icon-holder
inside the element with IDfeature-links-holder
. - Set up a click handler on all of these elements:
- removes the ‘opened’ class from all of these icons, i.e. it clears ‘opened’ from the previously open element. The opened class is probably a highlight around the icon.
- sets the ‘opened’ class on this icon, presumably highlighting it.
- clears the ‘show-details’ class from any elements inside ID
feature-holder
that currently has the class; again there’s probably only one of these, the currently displayed feature - adds the ‘show-details’ class to the element inside
feature-holder
that has a class name matching the ID stored with the icon clicked. This will presumably show the feature elsewhere on the page.