In javascript this inside a function represents the context in which the function invoked on, if a method is invoked without a context it will be the window object(or undefined in strict mode).
In jQuery event handlers this
represents the dom element reference on which the handler is registered on so in your case this
refers to the li
element. in case of event delegation this
will refer to the actual target of the handler like if an li
was targeted by the handler($(document).on('click', 'li', function(){...})
) then this
will be the li
element
Another option instead of using this
will be the currentTarget property of the event object
$(".controls li").click(function (e) {
// or $(e.currentTarget)
$(this).siblings().removeClass("selected");
$(this).addClass("selected");
color = $(this).css("background-color");
});
Demo: Fiddle