How to convert from RGB to color name?

How to convert from RGB to color name?

I'm new with jQuery and I've run into a snag. 

I have css set up and <divs> to display a circle and two squares on the page. I wanted to have an alert provide the background color as well as a shape name. When I used the following code, I get back the RGB code:

          $("div").click(function(){
if ($(this).attr("id") == "circle") {
alert("You have clicked a " + $(this).css("background-color" ) + " circle!");
} else {
alert("You have clicked a " + $(this).css("background-color" ) + " square!");
}
});

The alert says, "You have clicked a rgb(0, 128, 0) circle!"

Is there a way, given that I only have basic knowledge, to make it give its color name instead?

Thanks for the help.