문제

I don't particularly understand why an image would work in a span, but not by itself.
See complete example here.

JS

 $(document).ready(
     function ()
     {
        $('#banner').hover( function(event){ $(this).children().hide("slow");}
                          , function(event){ $(this).children().show("slow");}
                          );
     }
  );

HTML

<div id="banner">
   <span><img src="http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif" title="Image" alt="Image"/></span>
</div>

vs

<div id="banner">
   <img src="http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif" title="Image" alt="Image"/>
</div>
도움이 되었습니까?

해결책

I think really the element needs to be wrapped in a DIV. For my site, a larger image is having problems hiding; it's only hiding vertically instead of vertically and horizontally.

Wrapping in the DIV fixed this.

I haven't taken a greater look at how jQuery is performing the hide(), but this kind of makes sense, since a DIV is a block element and SPAN are not.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top