get mouse click if inside a div or not

Use this Code :

$("body > div").click(function() {
    if ($(this).attr("id") == "in_or_out") {
        // inside
    } else {
        // not inside
    }
});
$("body > div").click(function() {
    if ($(this).attr("id") == "in_or_out") {
        // inside
    } else {
        // not inside
    }
});
  1. <code>
  2. $("body > div").click(function() {
  3. if ($(this).attr("id") == "in_or_out") {
  4. // inside
  5. } else {
  6. // not inside
  7. }
  8. });
  9. </code>
<code>
$("body > div").click(function() {
    if ($(this).attr("id") == "in_or_out") {
        // inside
    } else {
        // not inside
    }
});
</code>
OR

$(document).mouseup(function (e)
{
    var container = $("YOUR CONTAINER SELECTOR");

    if (container.has(e.target).length === 0)
    {
        container.hide();
    }
});
$(document).mouseup(function (e)
{
    var container = $("YOUR CONTAINER SELECTOR");

    if (container.has(e.target).length === 0)
    {
        container.hide();
    }
});
  1. <code>
  2. $(document).mouseup(function (e)
  3. {
  4. var container = $("YOUR CONTAINER SELECTOR");
  5. if (container.has(e.target).length === 0)
  6. {
  7. container.hide();
  8. }
  9. });
  10. </code>
<code>
$(document).mouseup(function (e)
{
    var container = $("YOUR CONTAINER SELECTOR");

    if (container.has(e.target).length === 0)
    {
        container.hide();
    }
});
</code>

Popular posts from this blog

Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=xx.0.0.0, Culture=neutral, PublicKeyToken='xxx' or one of its dependencies.

C# Crop white space from around the image

The specified version string contains wildcards, which are not compatible with determinism.