I have an element, #i1
, that is below another element, .close_button
, and they each have a click event associated with them...the former's is called clickFade()
while the latter's event is a anonymous function that is defined within the execution of the aforementioned clickFade()
.
When clickFade()
is called by clicking on #i1
, the parent div,#welcome
, is fadedTo opacity .1 and #A
is fadedIn. Also, unbind()
is called for #i1
and the anonymous function mentioned above that is associated with a click event on .close_button
is defined. This function just reverses the effects that clickFade()
has when a close_button image is clicked.
I don't think the problem is a z-index issue (because I've tried it already and the close_button image is always visible on top). I also don't think it's a binding issue because the button works, but only when there's nothing underneath of it...for example, if the button is half overlapping one of the background images like #i1
, the half that isn't on top of #i1
will trigger the event while the other half will not.
What's the problem here and how can I fix it?
Here are the gists for the HTML, CSS, and JS; here's the relevant code:
HTML:
<div id="welcome">
<p id="welcomeText">Welcome</p>
<img src="imgs/img1.jpg" id="i1" alt=null/>
</div>
<div id="A">
<img src='imgs/close_button.gif' class='close_button' alt=null
style="width: 10%; height: 10%"/>
</div>
JS:
function clickFade() {
$('#welcome').fadeTo('slow',.1);
$('#i1').unbind('click',clickFade);
$('#i1').unbind('mouseover',mouseOverFunc);
switch (this.id) {
case "i1":
$('#A').fadeIn('slow');
$('.close_button').click(function() {
$('#A').fadeOut('slow');
$('#welcome').fadeTo('slow',1);
$('#i1,#i3,#i5').click(clickFade).mouseover(mouseOverFunc);
});
break;
.
.
.
}
}