views:

71

answers:

1

I have a <div> with two floated elements inside of it. I'm using jQuery to attach a click event handler to this <div>. The handler only gets called when I click one of the two floated elements. The empty space inside of the <div> does not work.

Here's what the markup looks like:

<div class="wrapper">
  <h4>Some lovely header text here</h4>
  <img src="images/plus.png"/>
  <div style="clear: both;"/>
</div>

Here's my Javascript (I'm using some other events, too):

// Expand scenarios when clicked on
scenario_header.live("click", function() { 
  $(this).toggleClass("expanded");
  $("+ div", this).slideToggle();
});

// Toggle hover class when hovering
scenario_header.live("mouseover", function() {
  $(this).toggleClass("hover");
});
scenario_header.live("mouseout", function() {
  $(this).toggleClass("hover");
});

This works perfectly in Firefox. Any ideas?

+1  A: 

I guess you have to apply some additional CSS so that the wrapper DIV really wraps its children. Something like this should be enough:

div {
 overflow: hidden;
 display: inline-block; /* weird stuff, but it's needed for IE6 */
}
div {
 display: block; /* needed to reset display for non IE6 browsers */
}
Ionuț G. Stan
Cool, although only setting `display: inline-block;` was enough. I'll accept your answer if you fix it (I don't feel right accepting it if it's a little wrong). Up-vote in either case :)
Mark A. Nicolosi
Awww. Now I get it. Without setting `display` back to `block` it no longer looks right in Firefox. Thanks Ionut!
Mark A. Nicolosi
Thanks, Mark. I modified the second comment. Indeed, it's needed for FF.
Ionuț G. Stan