Edit in JSFiddle

var nocontext = document.getElementById('nocontext');
var otherdiv = document.getElementById('otherdiv');

var switchClass = function (el, cl) {
    if (el.className == 'divDefault') {
        el.className = 'divDefault ' + cl;
    } else {
        el.className = 'divDefault';
    }
}

nocontext.addEventListener('contextmenu', function (e) {
    switchClass(nocontext, 'yellow');
    e.preventDefault();
});

otherdiv.addEventListener('contextmenu', function (e) {
    switchClass(otherdiv, 'blue');
    e.preventDefault();
});
<div id="nocontext" class="divDefault">right click here</div>
<div id="otherdiv" class="divDefault">right click here, too</div>
.divDefault {
    width: 150px;
    height: 150px;
    background-color: #ddd;
    border: 1px solid #333;
    margin: 5px;
    padding: 5px;
    color: #333;
}
.yellow {
    background-color: #FFCC00;
}
.blue {
    background-color: #3B83BD;
    color: #fff;
}