So currently I have a image inside a div in such a way:
<div onclick="doSomething()">
<img onclick="doSomethingElse()" src="image.png"/>
</div>
But clicking on the image calls both doSomething() and doSom开发者_如何学CethingElse(). I'd only like it to doSomethingElse().
I "need" to have the containing div "doSomething()" so getting rid of that is not an option.
Any ideas?
Inside of doSomethingElse(), call event.stopPropagation().
var doSomethingElse = function(event) {
event.stopPropagation();
// ...
}
加载中,请稍侯......
精彩评论