简体   繁体   中英

Select all elements into a div with css

I'm trying to select all elements into a div, so when I put the mouse outside do something. Selecting directly the div's id is not working properly. There are some way to select an element and all their child?

$("...").mouseout(function(){

});

I have a div and other div into it that appear on mouse over, but when I try to hide it after appear with mouse out of it and leave the father div, the div is still there.

I tryed something like:

$(".release").mouseover(function(e){
    var selected_row = $(this).attr('id');
    var request_id = $(this).attr('id').slice(8);

    var position_top = $('#'+selected_row).offset().top;
    var position_left = $('#'+selected_row).offset().left;

    jQuery("#request_notes").css( "display", "inline" );
    jQuery("#request_notes").css( "position", "absolute" );
    jQuery("#request_notes").css( "top", position_top );
    jQuery("#request_notes").css( "left", mouse_left );

});

$("#request_notes").mouseout(function(){
    jQuery("#request_notes").css( "display", "none" );
});

When I do mouse out of the father div, the one that appear is still there. So I would like to do mouse out, of the father and his child.

http://jsfiddle.net/sebasparola/vRqH4/6/

try

$("#request_notes").mouseout(function(){
    $(this).hide();
});

When you select an element, you already have its children. You can use built in jquery functions like find() to perform actions on the element's children.

If you're looking for a specific way to build a generic selector, you can pass jquery a comma separated list of elements you're looking for, just like in CSS. ie $("div, p, span, h1, h2")

代替使用mouseout使用mouseleave

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM