SO fiddle
Test Fiddle mainly for SO Questions
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
<div id="page" style="background-image: url(xxx)">Click here to test the code</div>
<div id="page2">Click here for the negative test</div>
CSS
.clicked { color:red; }
#page.bg { color:green; }
JavaScript
$("#page, #page2").click(function () {
$(this).addClass("clicked");
$(this).addClass(function () {
return $(this).css("background-image") ? "bg" : "";
});
});