属性のHTML
属性のHTMLは、
構文
以下は構文です-
1. forの戻り値 属性-
labelObject.htmlFor
例
forの例を見てみましょう 属性-
<!DOCTYPE html>
<html>
<head>
<title>Label htmlFor</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Label-htmlFor</legend>
<label id="CurrentEditor" for="editorTwo">Current Editor:</label><br>
<input type="text" id="editorOne" placeholder="editorOne">
<input type="text" id="editorTwo" placeholder="editorTwo">
<input type="button" onclick="getEventData()" value="Change Editor">
<div id="divDisplay">Label for attribute set as editor two</div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var labelSelect = document.getElementById("CurrentEditor");
function getEventData() {
if(labelSelect.htmlFor === 'editorTwo'){
divDisplay.textContent = 'Label for attribute set as editor one';
labelSelect.htmlFor = 'editorOne';
}
}
</script>
</body>
</html> これにより、次の出力が生成されます-
1)[エディタの変更]をクリックする前に ボタン-
2)[エディタの変更]をクリックした後 ボタン-
-
HTMLに必要な属性
HTML必須属性は、HTMLドキュメントでフォームを送信する前にHTML要素に入力する必要があることを定義します。 入力に適用できます 、選択 、および textarea HTML要素。 構文 以下は構文です- <tagname required></tagname> 例 HTMLに必要な属性の例を見てみましょう- <!DOCTYPE html> <html> <style> body { color: #000; he
-
HTMLパターン属性
HTMLパターン属性は、HTML要素の値がHTMLドキュメントで一致する正規表現を定義します。 構文 以下は構文です- <input pattern=”regular expression”> HTMLパターン属性の例を見てみましょう- 例 <!DOCTYPE html> <html> <style> body { color: #000; height: 100vh;