开发者

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

开发者 https://www.devze.com 2022-12-28 13:18 出处:网络
how do i get the id under another id in an if statement? $(\'#mainmenu\').mouseenter(function ()开发者_如何学编程 {

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

精彩评论

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