views:

45

answers:

3

I want to make an empty div react to click.

HTML

<div id="closeButton"></div>

CSS

#closeButton {
height:100px;
position:absolute;
right: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?

A: 

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">
galambalazs
A: 

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.

heffaklump
you can accept your answer if the problem is solved.
galambalazs
A: 

try this:

$(function(){
  $('#closeButton').click(function(){
      alert("yo");
  });
})
Dragoon zhang