HTML returnValue 事件屬性
HTML returnValue 事件屬性返回並修改當前事件是否取消。
語法
以下為語法
1. 返回 returnValue
event.returnValue
2. 新增 returnValue
event.returnValue=”true | false”
我們來看看 HTML returnValue 事件屬性的一個示例
示例
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #000;
height: 100vh;
background-color: #FBAB7E;
background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%);
text-align: center;
}
input {
width: 200px;
height: 2rem;
}
.msg {
font-size: 1.5rem;
}
</style>
</head>
<body>
<h1>HTML returnValue Event Property Demo</h1>
<input type="text" placeholder="Enter your name" onfocus="show(event)">
<p class="msg"></p>
<script>
function show(event) {
document.querySelector('.msg').innerHTML = 'Is onfocus event is active on above input field? ' + event.returnValue;
}
</script>
</body>
</html>輸出

現在嘗試在輸入框中輸入值,使其獲得焦點,以顯示 returnValue 事件屬性的值。

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP