There may be several solutions.
If you wish to use only CSS (and no JavaScript), you could do something like
#div {
...
transition:width 3600s,height 3600s;
}
#div:hover {
...
transition:width 1s,height 1s;
}
It may be a cheap solution, but it's CSS-only and it works well. The transition to set width/height back to the starting values is set to a high amount of time. So the transition happens, but it's not visible to the eye. Example via jsfiddle
With JavaScript I'd prefer giving a class to the element instead of setting the values via JS. I believe things like width/height should be set in CSS-files not in JS.
CSS:
.hovered {
width:300px;
height:300px;
}
JS:
document.querySelector("#div").addEventListener("hover",function() {
this.classList.add("hovered");
});
JS/jQuery:
$("#div").hover(function() {
$(this).addClass("hovered");
});