Jquery detect the main parent div
<p>My problem that i am having is i want to get the parent id form a click within it. The problem comes when i have stacks of divs like as follows:</p>

<pre><code>&lt;div id="files"&gt;
&lt;div id="F1"&gt;&lt;span&gt;Label&lt;/span&gt;&lt;/div&gt;
&lt;div id="F2"&gt;&lt;span&gt;Label&lt;/span&gt;&lt;/div&gt;
&lt;div id="F3"&gt;&lt;span&gt;Label&lt;/span&gt;&lt;/div&gt;
&lt;div id="F4"&gt;&lt;span&gt;Label&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>I have the script to the point that if I click the F# div areas it will refer to its parent which is files, but if I was to click the label span, it would refer back to its parent with the is of the id F#. I basically need it to the point that if there is a click within the files div, I can get the id even though no exposed area of that div is showing.</p>

<p>The jquery I was using was this:</p>

<pre><code>$(window).load(function(){

    $(document).bind("contextmenu", function(event) { 
        event.preventDefault();

        var pid = event.target.parentNode.id;
        var id = event.target.id;
        //$(pid).val().substring(0,4)
        $(this).parent();
        //alert((pid).val().substring(0,4));
        var pid = (pid).substring(0,6);    

        if(pid === "files" || pid === "filess" || pid === "folder"){
             $("&lt;div class='custom-menu'&gt;
                  &lt;a onclick='fileHide()'&gt;Open&lt;/a&gt;
                  &lt;br/&gt;
                  &lt;a onclick='newFile()'&gt;Rename&lt;/a&gt;
                  &lt;br/&gt;
                  &lt;a href='#'&gt;Share Folder&lt;/a&gt;
                  &lt;br/&gt;
                  &lt;a onclick='deleteFile(\""+ id +"\")'&gt;Delete&lt;/a&gt;
                &lt;/div&gt;").appendTo("body")
                        .css({top: event.pageY + "px", left: event.pageX + "px"});
        }else{
             $("&lt;div class='custom-menu'&gt;
                  &lt;a onclick='fileHide()'&gt;Upload&lt;/a&gt;
                  &lt;br/&gt;
                  &lt;a onclick='newFile()'&gt;New Folder&lt;/a&gt;
                  &lt;br/&gt;&lt;a href='#'&gt;Share Folders&lt;/a&gt;
                  &lt;br/&gt;&lt;a href='#'&gt;Deleted files&lt;/a&gt;
                &lt;/div&gt;").appendTo("body")
                        .css({top: event.pageY + "px", left: event.pageX + "px"});
        }

    }).bind("mouseup", function(event) {
        $("div.custom-menu").hide();
    });            
});
</code></pre>
