HTMLDOM入力URL名プロパティ
HTML DOM入力URLnameプロパティは、入力URLのnameプロパティの値である文字列を返します。ユーザーはそれを新しい文字列に設定することもできます。
構文
以下は構文です-
- 文字列値を返す
inputURLObject.name
- 名前の設定 文字列値の属性
inputURLObject.name = ‘String’
例
入力URL名の例を見てみましょう プロパティ-
<!DOCTYPE html>
<html>
<head>
<title>Input URL name</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>URL-name</legend>
<label for="URLSelect">Employee URL:
<input type="url" id="URLSelect" value="https://www.example.com" name="Jack">
</label>
<input type="button" onclick="getName()" value="Who is the Owner? ">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputURL = document.getElementById("URLSelect");
function getName() {
if(inputURL.value === 'https://www.example.com')
divDisplay.textContent = 'Above URL belongs to '+inputURL.name;
else
divDisplay.textContent = 'Above URL belongs to no one!';
}
</script>
</body>
</html> 出力
これにより、次の出力が生成されます-
「所有者は誰ですか?」をクリックする前に ボタン-
「所有者は誰ですか?」をクリックした後 ボタン-
-
HTMLDOM入力URLプレースホルダープロパティ
HTML DOM入力URLプレースホルダープロパティは、入力テキストがどのように表示されるかについてユーザーにヒントを与えるために一般的に使用される文字列を設定/返します。 構文 以下は構文です- 文字列値を返す inputURLObject.placeholder プレースホルダーの設定 stringValueへ inputURLObject.placeholder = stringValue 例 入力URLプレースホルダープロパティの例を見てみましょう- <!DOCTYPE html> <html> <head> <title>I
-
HTMLDOM入力URLパターンプロパティ
HTML DOM入力URLパターンプロパティは、URL入力に対応する正規表現を設定/返します。パターン属性の値は、URLフィールドに入力されたテキストと照合されます。 Sytax 以下は構文です- 正規表現を返す inputURLObject.pattern パターンの設定 正規表現へ inputURLObject.pattern = ‘RegExp’ 例 入力URLパターンの例を見てみましょう プロパティ- <!DOCTYPE html> <html> <head> <title>Input URL pa