Nachdem er viel Zeit in der jQuery-Dokumentation, kam ich mit Diese Lösung, die funktioniert. @Gaby @brad danke für die Eingabe
//listen for clicks and mousemovement in the header/footer
//and pass event through to the content div where applicable
$("#header, #footer").bind("click mousemove", function(e){
//only intercept event if it did not fall on an "a" tag
//within header/footer
if(!$(e.target).is("a")){
e.preventDefault();
$("#container").trigger(e);
return false;
}
});
$("#container").bind("click mousemove", function(e){
e.preventDefault();
//get the coordinates of all "a" decendents of #container
$(this).find("a").each(function(){
var pos = $(this).offset();
var height = $(this).height();
var width = $(this).width();
//determine if this event happened
//within the bounds of this "a" element
if((e.pageX >= pos.left && e.pageX <= (pos.left + width))
&& (e.pageY >= pos.top && e.pageY <= (pos.top + height))){
//if event type is mousemove, trigger hover
if(e.type == "mousemove"){
$(this).css("text-decoration", "underline");
//else, pass trigger on to element as is (click)
} else {
window.location = $(this).attr("href");
}
}
});
//prevent bubbling
return false;
});
haben Sie einen 'click' Handler an das' # container' Element angehängt? –