<div class="myShips" id="161">
<img src="img/ships/red/sc.png" id="Ship161"
style="-webkit-transform: rotate(45deg);">
<div class="hpBarRed"><div class="hpBarGreen" style="width:15px;">
</div></div>
</div>
I wish to have a JQ click function, that will do something with the ID of the .myShips div I click. However, the image inside the div is the same size of that div, so it is above it. So basically I want to be able to click anywhere in that div, and activate the function (the alert and append are just for testing):
$( '.myShips' ).click(function() {
$("#hello").append("/*/");
//alert($(this).attr('id'));
});
I tried putting a larger z-index of the .myShips class but that did not work. what is my best option? Will I have to add another class for the images and then have 1 of possible 2 functions being called?
EDIT: The problem is with absolute positioning. .myShips is inside another div that is absolutely positioned. I added the same function for click, but for ALL divs that are clicked. So when I click an image, its ID is not alerted, neither is the .myShips id alerted, but its parent id is alerted, and then 2 more divs that are its parents are alerted. So I believe the prblem is with position: absolute