Home >Web Front-end >HTML Tutorial >Problem with onClick event of nested div_html/css_WEB-ITnose

Problem with onClick event of nested div_html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-24 11:47:581084browse

I added the onClick event to the outer div in the code below, so that when the mouse clicks on the div, it will jump.
But I added some other effects to the picture, so the jump event cannot be triggered when the mouse clicks on the img in the middle.
How to do this?

<div class="box" onClick="window.open('interest/cloud.php');">	<div class="texts">		<div class="title">云</div>	</div>	<div class="images">		<img src="angel.gif" />	</div>	<div class="texts">		<div class="content">云</div>		<div class="author">云</div>	</div></div>

In short, when the mouse clicks on an area other than the picture, the jump event is triggered, and when the picture is clicked, my other events are executed.


Reply to discussion (solution)

<div class="box" onClick="window.open('interest/cloud.php');">	<div class="texts">		<div class="title">云</div>	</div>	<div class="images" onClick="event.cancelBubble = true">		<img src="angel.gif" />	</div>	<div class="texts">		<div class="content">云</div>		<div class="author">云</div>	</div></div>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn