JS prevent the occurrence of an event of default

If html tags are defined in two events (includes a custom function), then the system will first execute user-defined functions, and then execute the default label function. If you want to prevent the default function is executed after executing the custom function, can be set as follows:

<a href="www.baidu.com" οnclick="return do()"> 测试阻止a标签默认事件执行</a>

<script>
        function do() 
        {
			...;
			return false;
        }
</script>

If you want to perform a default event, then return true

Published 59 original articles · won praise 2 · Views 4645

Guess you like

Origin blog.csdn.net/lch551218/article/details/104769259