Using srcElement in Firefox
I have a problem in Firefox. I can't use window.event.srcElement.id
in Firefox and flow code doesn't work in Firefox. Please help me.
$(document).ready(function(e) {
$("img[rel]").ove开发者_JAVA百科rlay(function() {
try {
if (window.event) {
var sid = window.event.srcElement.id;
document.getElementById("SelectedNewsID").value = sid;
}
else {
//alert("Error.");
}
}
catch (err) {
alert("Error");
}
});
});
window.event.srcElement works only in IE. For all other browsers window.event does not work. If you are using JQuery to bind the click event or any other event you will get the event object in which event.target will give you the target element.
Try this
$(document).ready(function(e) {
$("img[rel]").click(function(e){
$("#SelectedNewsID").val(e.target.id);
}).overlay();
});
精彩评论