Solved

Which element is selected by a left or right click?

Posted on 2016-07-26
4
25 Views
Last Modified: 2016-08-04
I have several folder icons that are created with the template:

<div id='folderTemplate' class="template openclosed_folder_icon subfolder" style="position:absolute; top:'30'; left:'100';">
           <img class="folder_icon" src="images/folder_closed.png"  alt="closed folder"  />
           <div class="folder_label" >name</div> 
           <img class='folder_redX' src='images/redX.png' alt='redX' title='Delete this gallery' />
    </div>  

Open in new window


The folders look like this:
folders
If I left-click most folders, the e.target that comes into jQuery is the first <img> element, on line 2 above.  And if I right-click these folders with Chrome Debugging turned on, to inspect them, the element selected is this first <img> element.   But one of the folders gives me the outer div, at line 1,  when I left click it or right-click it.  Does anyone have an idea what's going on?  What controls which element is actually selected by a left or right click?

Thanks
0
Comment
Question by:steva
  • 2
  • 2
4 Comments
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41730767
Can we see a link please or can you at least post your html and css
0
 

Accepted Solution

by:
steva earned 0 total points
ID: 41731580
I solved this but it wasn't what I thought. The problem was that the template div for the folder to the left extends too far right and overlaps the folder on the right:
overlap.jpg
So when I thought I was clicking on the images folder I was actually clicking on the template div of the Gallery folder, which blocked the mouse click from reaching the images folder. The click wasn't bringing up the template div of the images folder. It was bringing up the template div of the Gallery folder that overlayed the images folder. Fix was to make the width of the template div just enough to hold the folder name so there won't be any more overlapping of folders.
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41731604
That is why a link is helpful - with the Inspect Element window you can hover over the element and see its extent and bounds - makes it easier to solve issues such as this.

Having said that though - hard coding a width is not a great solution - you should try to make your code autofit its available space - that way you won't run into this sort of problem.
0
 

Author Closing Comment

by:steva
ID: 41742155
It was the only correct answer.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now