开发者

how do i get the id under another id in an if statement?

how do i get the id under another id in an if statement?

$('#mainmenu').mouseenter(function ()开发者_如何学编程 {
  if ( $(this).???('#a')) {
        }  

  if ( $(this).???('#b')) {
        }  
});

<div id="mainmenu">
    <div id="a"></div>
    <div id="b"></div>
</div>


You want the find method.

$(this).find('#a')


$('#mainmenu #a, #mainmenu #b').mouseenter(function(){
 // code for something cool...
});

HTH.


Try this:

$('#mainmenu').mouseenter(function () {

  if ($('#a', $(this)) {
    // your code here...............
  }  

  if ($('#b', $(this)) {
    // your code here...............
  }  

});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜