“Klik di luar kotak jQuery” Kode Jawaban

Div Outside Click Event JQuery

window.addEventListener('click', function(e){   
  if (document.getElementById('clickbox').contains(e.target)){
    // Clicked in box
  } else{
    // Clicked outside the box
  }
});
Shy Sandpiper

Klik di luar kotak jQuery

$(document).click(function(){
 $("#try").hide(); 
});

$("#try").click(function(e){
  e.stopPropagation(); 
});
A D Bhowmick

Klik di luar elemen jQuery

    $(document).click(function (event) {
        var $target = $(event.target);
        if (!$target.closest('.modal-dialog').length && $('.modal-dialog').is(":visible")) {
            console.log("clicked outside the element")
        }
    });
Filthy Flatworm

Klik luar pada Div Sembunyikan Div di JQeury

<script>
$(document).mouseup(function(e){
    var container = $("#elementID");

    // If the target of the click isn't the container
    if(!container.is(e.target) && container.has(e.target).length === 0){
        container.hide();
    }
});
</script>
Talented Toad

Klik di luar kotak jQuery

<body>
  <p id="try">Lorem ipsum is placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts and visual mockups.

</p>
</body>
A D Bhowmick

Jawaban yang mirip dengan “Klik di luar kotak jQuery”

Pertanyaan yang mirip dengan “Klik di luar kotak jQuery”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya