当我单击 mainDiv 时,将调用该函数,当我单击 subDiv 时,mainDiv()
将调用两个函数。mainDiv()
subDiv()
subDiv()
当我单击 subDiv 时,我只想调用该函数。我怎样才能做到这一点?
代码:
<div onclick="mainDiv()">
show main div
<div onclick="subDiv()">
show sub div
</div>
</div>
<script type="text/javascript">
function mainDiv(){
alert("main div is clicked");
}
function subDiv(){
alert("sub div is clicked");
}
</script>