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...............
}
});
精彩评论