Edit in JSFiddle

var $demo = document.getElementById('demo');

$demo.onclick = function () {
    $demo.style.width = '200px';
    $demo.style.transition = 'all 2s';
};

$demo.ontransitionend = function () {
    $demo.innerHTML = 'done';
};

$demo.addEventListener('transitionend', function () {
    $demo.style.backgroundColor = '#fcc';
});
<div id="demo" style="width:100px;height:100px;background:#eee;"></div>