Password select()メソッド
Password オブジェクト
定義と用法
select() メソッドはパスワードフィールド内のテキストを選択するために使用されます
構文
passwordObject.select()
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザが select() メソッドをサポートしています
例
例
以下の例では、パスワードフィールド内のテキストを選択できます:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function myFunction(){
document.getElementById("pwd").select();
}
</script>
</head>
<body>
<form>
パスワード: <input type="password" id="pwd" value="thgrt456">
</form>
<button type="button" onclick="myFunction()">内容を選択</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function myFunction(){
document.getElementById("pwd").select();
}
</script>
</head>
<body>
<form>
パスワード: <input type="password" id="pwd" value="thgrt456">
</form>
<button type="button" onclick="myFunction()">内容を選択</button>
</body>
</html>
試してみる »
Password オブジェクト その他の拡張