我可以在wordpress的自定义链接菜单上添加onClick()事件吗?

在WordPress中, 使用主题时, 如何防止自定义链接上发生点击事件。我正在考虑添加以下内容:

onClick="return false"

我试图阻止页面在单击时意外滚动。


#1


你可以使用主题版吗?如果是这样, 你可以尝试使用以下代码, 例如

添加footer.php

如果你没有访问权限, 但是主题有一些自定义字段。

<script>
        //JQUERY
        (function ($) {
            $('a[href=#]').click(function (e) {
                e.preventDefault();
            })
        })(jQuery)

        //JS PURE
        document.querySelectorAll('a[href="#"]').forEach(function(ele, i){
            ele.addEventListener('click', function (e) {
                e.preventDefault();
            })
        })
</script>

来源:

https://www.srcmini02.com/62861.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_42101.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?