开发者

jquery: hide/show div2 inside other div1 on mouseover

开发者 https://www.devze.com 2022-12-30 19:36 出处:网络
I have something like this: <div id=\"wrap1\"> <div id=\"util1\"> </div> bla bla </div>

I have something like this:

<div id="wrap1">
<div id="util1">
</div>
bla bla
</div>

<div id="wrap2">
<div id="util2">
</div>
bla bla
</div>

<div id="wrap3">
<div id开发者_Go百科="util4">
</div>
bla bla
</div>

...

I need to show the "util" divs when cursor is over the "wrap" div and hide it back when cursor leaves the "wrap" div


$("div[id^=wrap]").hover(function() {
    $(this).find("div[id^=util]").show();
}, function() {
    $(this).find("div[id^=util]").hide();
});

See:

  • http://api.jquery.com/attribute-starts-with-selector/
  • http://api.jquery.com/hover/
0

精彩评论

暂无评论...
验证码 换一张
取 消