输入框按回车自动搜索,在输入框中按下回车键时执行js函数,阻止默认的表单form搜索,你可以使用 JavaScript 来监听键盘事件并阻止默认的表单提交行为。

zblog1年前zblog问题解答34
输入框按回车自动搜索,在输入框中按下回车键时执行js函数,阻止默认的表单form搜索,你可以使用 JavaScript 来监听键盘事件并阻止默认的表单提交行为。
document.addEventListener('DOMContentLoaded', (event) => {
        const form = document.getElementById('login');
        form.addEventListener('keydown', function (event) {
            if (event.key === 'Enter') {
                event.preventDefault(); // 阻止默认的表单提交行为
                sousuo(); // 调用 chaxun() 函数
            }
        });
    });


相关文章

zblog的 $this->lang['msg']['operation_failed'],lang到底都配置什么?在哪里查看?都有哪些值?zblog语言包

zblog的 $this->lang['msg']['operation_failed'],lang到底都配置什么?在哪里查看?都有哪些值?zblog语言包

在上一篇文章《zblog函数ShowHint('good')中good是怎么来的?允许哪些,不允许哪些?》源码中有一个 $content = $this->lang[&...

重启!

重启!

重启mysql 和 phpservice mysqld restart service php-fpm restart或systemctl restart mysqldsystemctl r...

php文件名字 去掉特殊字符 zblog实现

FormatString($article->Title, '[filename]') zb_system/function/c_system_common.ph...

php curl 典型案例代码 curl例子 curl_init() curl_setopt

      $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url);...