I've created the following function in Jquery
function menuItem(x,i) {
var imgALT = $(x).text();
$(x).mouseover(function()
{
$(x).parent().parent().parent().children("img").attr("src", "menu/menu"+i+".jpg");
$(x).parent().parent().parent().children("img").attr("alt", imgALT);
$(x).parent().children("span").css("color", "#FFFFFF");
$(x).css("color", "#CA0109");
});
};
And I trigger it using the following:
<span onmouseover="menuItem(this,'09-01')">月亮蝦餅 (2份)</span>
It works exactly as I intend it to, but only after I mouseover the span for the second time, not the first. I assume this is perhaps a loading issue of some kind? How should I go about ensuring it triggers on the first mouseover, as well as subsequent events?
Many thanks!