.Open{
background:#508;
}
.Close{
background:#fd3;
}
<div id='click'>click</div>
t = document.getElementById('click')
t.onclick = function(){
this.className = (this.className == 'Open')?' Close':'Open'
}
document.onclick = function(e){
if(e.target.id != 'click'){
t.className = ' Open'
}
}