Please tell me how I can execute the go2
function when I click on the button without executing the go
function
function go($i) { alert($i); } function go2($i) { alert($i); }
div { width: 200px; height: 200px; background: #eaeaea; }
<div onclick="go('159');"> <button onclick="go2('160');">Go 2</button> </div>
you need to use event.stopPropagation()
function go($i) { alert($i); } function go2($i) { event.stopPropagation(); alert($i); }
div { width: 200px; height: 200px; background: #eaeaea; }
<div onclick="go('159');"> <button onclick="go2('160');">Go 2</button> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.