It is a very typical convention where a developer will prefix a variable name with $
to indicate it is a jQuery object, and will have access to all the typical jQuery methods. It is not a selector.
In your example you have this: var $parent = $(this).parent();
. This is a reference to the DOM object, once you have saved that, you can use it multiple times:
You can do this:
$(this).parent().css('color', 'green');
$(this).parent().css('border', '1px solid pink');
$(this).parent().css('background', 'purple');
In this example, jQuery will select the $(this)
object, and then select its parent
You can also do this:
var $parent = $(this).parent();
$parent.css('color', 'green');
$parent.css('border', '1px solid pink');
$parent.css('background', 'purple');
You have saved the reference to the parent, and made jQuery only look it up once.
*Small sidenote: The css method can be done better, I did it this way for demo-purposes *