您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

当用户在 HTML 搜索字段中写入内容时执行脚本?

2025/8/8 16:31:08发布31次查看
使用html中的onsearch属性,在用户在搜索框中输入并按下enter或x键时执行脚本。
示例您可以尝试运行以下代码来实现onsearch属性 −
<!doctype html><html> <body> <p>search something and press enter.</p> <input type = "search" id="inputid" onsearch = "display()"> <p><strong>note:</strong> it won' work in internet explorer and firefox.</p> <p id="test"></p> <script> function display() { var a = document.getelementbyid("inputid"); document.getelementbyid("test").innerhtml = "searched for - " + a.value; } </script> </body></html>
以上就是当用户在 html 搜索字段中写入内容时执行脚本?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product