You're example does nothing.. You'll need a <span> tag with an onMouseOver that sets the URL of an image to the URL of the yellow rectangle. Secondly, You'll add an onMouseOut to set the URL back to a hidden image (1x1 transparent gifs work great). That span tag will go around the object you want to be activated when the mouse cruises over it (such as your "My favorite color is purple" text).
I'm just going to freeform here, but you should be able to get a pretty good idea:
Code:
<script language="JavaScript">
function swapImgs(obj, img){
var sNewImg = new Image();
sNewImg.src = img;
document.getElementById(obj).src = sNewImg.src;
}
</script>
<span onMouseOver="swapImgs('myImg', 'triangle.gif');" onMouseOut="swapImgs('myImg', 'blank.gif');">My favorite color is purple.</span>
<img id="myImg" src="blank.gif">