I am facing an issue with the following list structure:
<ul id="menu">
<li style="background-image:url('Images/X-AFH-Company-Office-Background.png')" id="office">
<div >Company / Office</div>
<img src="Images/Employee.png" onmouseover="this.src='Images/Employee-Stroke.png'" onmouseout="this.src='Images/Employee.png'" />
<img class="stroke" style="display:none" src="Images/Employee-Stroke.png" />
</li>
<li style="background-image:url('Images/X-AFH-Hospital-Clinic-Background.png')" id="clinic" >
<div >Hospital / Clinic</div>
<img src="Images/Doctor.png" onmouseover="this.src='Images/Doctor-Stroke.png'" onmouseout="this.src='Images/Doctor.png'" />
<div style="width:100px;height:350px;position:absolute;left:0;top:0;z-index:21"></div>
</li>
<li style="background-image:url('Images/X-AFH-University-School-Background.png')" id="school">
<div >University / School</div>
<img src="Images/Student.png" onmouseover="this.src='Images/Student-Stroke.png'" onmouseout="this.src='Images/Student.png'" />
</li>
etc...
I am trying to implement a click event on the main <li>
element in the list. However, the <img />
tags within the <li>
are extending beyond its boundaries and triggering the click event unintentionally.
Is there a way to only apply the click event to the list item itself and not its child elements, even if they exceed the width and height of the main <li>
?