The jQuery API of .parent() allows you to target the parent of the specified element(s) and optionally target a specific type of parent element.

Example of .parent()

$("a").parent("li").css("background", "#564843");


If nothing is specified with .parent() inside the parentheses, then it selects the closest parent element. If you add an element, class or id, it will go up to the next parent element that matches that parameter.

In the example below

    var species = "." + $(this).attr("id");

Here is the result