HTML DOM 입력 버튼 양식 속성
정의 및 사용
버튼 참조를 포함하는 형태로 재산 반환을 형성한다.
버튼을 포함하는 경우, 버튼을 포함하고 있지 않으면 폼 객체는, null을 반환합니다.
문법
buttonObject.form
브라우저 지원
모든 주요 브라우저는 양식 속성을 지원
예
예
다음 예는 양식이 포함 버튼의 ID를 반환합니다 :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
var x=document.getElementById("button1").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
<input type="button" onclick="displayResult()" value="显示包含按钮的表单id" id="button1">
</form>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
var x=document.getElementById("button1").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
<input type="button" onclick="displayResult()" value="显示包含按钮的表单id" id="button1">
</form>
</body>
</html>
»시도
버튼 객체