所属分类:web前端开发
示例
您可以尝试运行以下代码来实现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>