Aşağıdaki biçimlendirme kullanıyorum ve aynı sorunu kodlanmış:
<ul class="nav">
<li><a href="abc.html">abc</a></li>
<li><a href="def.html">def</a></li>
</ul>
Burada aşağıdaki mantığı kullandım:
$(".nav > li").click(function(e){
if(e.target != this) return; // only continue if the target itself has been clicked
// this section only processes if the .nav > li itself is clicked.
alert("you clicked .nav > li, but not it's children");
});
Tam soru açısından, bunun çalıştığını aşağıdaki gibi görebiliyorum:
$(".example").click(function(e){
if(e.target != this) return; // only continue if the target itself has been clicked
$(".example").fadeOut("fast");
});
veya tabii ki tam tersi:
$(".example").click(function(e){
if(e.target == this){ // only if the target itself has been clicked
$(".example").fadeOut("fast");
}
});
Umarım yardımcı olur.