觸發(fā) onsearch
屬性事件當用戶通過按ENTER鍵進行搜索時在< input> 元素與 type =“search”
。
我們還可以通過單擊字段中的“X”觸發(fā)事件。
沒有。
<elementName onsearch="script">
<input type="search">
![]() |
![]() |
![]() |
![]() |
![]() |
|
---|---|---|---|---|---|
onsearch |
Yes | No | No | Yes | Yes |
<!DOCTYPE html>
<html>
<body>
<input type="search" id="myInput" onsearch="myFunction()">
<script>
function myFunction() {
var x = document.getElementById("myInput");
console.log(x.value);
}
</script>
</body>
</html>
更多建議: