<div id="block1" onMouseOver="toggleActive('block2',1);" onMouseOut="toggleActive('block2',0);">текст1</div> <div id="block2">текст2</div>
function toggleActive(id, isActive) { document.getElementById(id).className = isActive ? 'active' : ''; }