Internet Explorer empty div link
I want to make an empty div react to click.
HTML
<div id="closeButton"></div>
CSS
#closeButton {
height:100px;
position:absolute;
righ开发者_JAVA技巧t:0;
top:0;
width:100px;
z-index:1000;
border:1px solid blue;
}
Javascript
$('#closeButton').click(function() {
alert("yo");
});
This works perfectly in Firefox, but not in Internet Explorer. Why?
I solved it by adding a 1x1 transparent png as background-image. This made the div render properly and possible to use for click functions.
It seems to be a wierd bug, and the only solution is to set IE in HTML4 standards-compliant mode
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Try this:
$(function(){
$('#closeButton').click(function(){
alert("yo");
});
})
精彩评论