Jquery click outside

 $(document).mouseup(function (e)

{

    var container = new Array();

    container.push($('#item_1'));

    container.push($('#item_2'));

    

    $.each(container, function(key, value) {

        if (!$(value).is(e.target) // if the target of the click isn't the container...

            && $(value).has(e.target).length === 0) // ... nor a descendant of the container

        {

            $(value).hide();

        }

    });

});

Không có nhận xét nào:

StaticImage

  import React , { useEffect , useRef } from "react" import { StaticImage } from "gatsby-plugin-image" impor...