「jQuery入門」select()イベントのサンプル
書式
$( “:input" ).select(function() {//some code }
テキストエリアの文字列を選択状態にしたり、選択範囲を変更した際に呼び出されます。
使用例
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>selectイベントのサンプル</title>
<style>
p {
color: green;
}
div {
color:red;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<p>テキストボックスの文字列をクリック、ドラッグ.</p>
<input type="text" value="テスト内容122">
<div class="cft"></div>
<script>
$( ":input" ).select(function() {
$( ".cft" ).text( "テキストボックスの文字を選択しました" ).show().fadeOut( 2000 );
});
</script>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>selectイベントのサンプル</title>
<style>
p {
color: green;
}
div {
color:red;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<p>テキストボックスの文字列をクリック、ドラッグ.</p>
<input type="text" value="テスト内容122">
<div class="cft"></div>
<script>
$( ":input" ).select(function() {
$( ".cft" ).text( "テキストボックスの文字を選択しました" ).show().fadeOut( 2000 );
});
</script>
</body>
</html>
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>selectイベントのサンプル</title> <style> p { color: green; } div { color:red; } </style> <script src="https://code.jquery.com/jquery-3.5.0.js"></script> </head> <body> <p>テキストボックスの文字列をクリック、ドラッグ.</p> <input type="text" value="テスト内容122"> <div class="cft"></div> <script> $( ":input" ).select(function() { $( ".cft" ).text( "テキストボックスの文字を選択しました" ).show().fadeOut( 2000 ); }); </script> </body> </html>