Gambar reproduksi:
Implementasi spesifik:
1. Konten Tag TexTarea
Salinan kode adalah sebagai berikut:
<span style = "font-size: 14px;"> <tr>
<td align = "kanan" valign = "atas"> Catatan: </td>
<td> <textarea name = "" id = "komentar" cols = "" baris = "" onfocus = "this.className = 'textarea220l'; this.onmouseout = ''; getAddfocus ('komentar');" Onblur = "this.className = 'textArea220'; this.onmouseOut = function () {this.className = 'TextArea220'}; LostAddFocus ('komentar');" onMouseMove = "this.className = 'TextArea220lg'" onMouseOut = "this.className = 'TextArea220'"> </textarea> </td>
</tr> </span>
2. Inisialisasi memungkinkan Anda untuk memasukkan hingga 50 kata saat mengklik tombol Tambah.
Salinan kode adalah sebagai berikut:
<span style = "font-size: 14px;"> $ ("#Pendahuluan"). Val ("Maksimal 50 kata dapat dimasukkan");
document.getElementById ("Pendahuluan"). style.color = "grey"; </span>
3. JS Script
Salinan kode adalah sebagai berikut:
<span style = "font-size: 14px;"> function getAddfocus (id) {// untuk pengantar dan catatan dalam operasi tambahan, TextArea mendapatkan fokus kotak input yang jelas
var textarea = document.geteLementById (id);
textarea.value = "";
textarea.style.color = "hitam";
}
Fungsi lostaddfocus (id) {// untuk pengantar dan catatan dalam operasi penambahan, jika tekstare kehilangan fokus dan kontennya kosong, pesan cepat akan ditampilkan
var textarea = document.geteLementById (id);
var textarea_value = textarea.value;
if (textarea_value == "") {
textarea.value = "maksimum 50 kata dapat dimasukkan";
textarea.style.color = "Grey";
}
} </span>
Referensi untuk Penggunaan Fokus TextArea yang ditulis oleh CSDN Friends:
Salinan kode adalah sebagai berikut:
<span style = "font-size: 14px;"> 1. Kotak teks menampilkan teks default:
<TextArea> Putih Dove Boy </TextArea>
<TextArea> Putih Dove Boy </TextArea>
2. Klik kotak teks dengan mouse, dan teks default menghilang:
<textarea onfocus = "if (value == 'white dove boy') {value = ''}"> white dove boy </textarea>
<textarea onfocus = "if (value == 'white dove boy') {value = ''}"> white dove boy </textarea>
3. Pindahkan mouse ke kotak teks, dan teks default menghilang:
<textarea onmouseover = "focus ()" onfocus = "if (value == 'white dove boy') {value = ''}"> white dove boy </extArea>
<textarea onmouseover = "focus ()" onfocus = "if (value == 'white dove boy') {value = ''}"> white dove boy </extArea>
4. Klik kotak teks dengan mouse, teks default menghilang, klik area mana pun di luar kotak teks, dan teks default muncul kembali lagi:
<textarea onfocus = "if (value == 'white dove boy') {value = ''}" oNblur = "if (value == '') {value = 'White Dove Boy'}"> White Dove Boy </TextArea>
<textarea onfocus = "if (value == 'white dove boy') {value = ''}" oNblur = "if (value == '') {value = 'White Dove Boy'}"> White Dove Boy </TextArea>
5. Pindahkan mouse ke kotak teks, teks default menghilang, mouse untuk keluar dari kotak teks, dan teks default muncul kembali:
<textarea onmouseover = "focus ()" onfocus = "if (value == 'white dove boy') {value = ''}" onmouseout = "blur ()" onblur = "if (value == '') {value = 'white dove boy'}"> white dove boy </textarea>
<textarea onmouseover = "focus ()" onfocus = "if (value == 'white dove boy') {value = ''}" onmouseout = "blur ()" onblur = "if (value == '') {value = 'white dove boy'}"> white dove boy </textarea>
6. Klik kotak teks dengan mouse, dan teks apa pun di kotak teks menghilang (termasuk teks default dan teks yang dimasukkan nanti):
<TextArea OnClick = "value =’ '"> White Dove Boy </pextarea>
<TextArea OnClick = "value =’ '"> White Dove Boy </pextarea>
7. Pindahkan mouse ke kotak teks, dan teks apa pun di kotak teks menghilang (termasuk teks default dan teks yang dimasukkan nanti):
<textarea onmouseover = "value =’ '"> White Dove Boy </pextarea>
<textarea onmouseover = "value =’ '"> White Dove Boy </pextarea>
8. Klik kotak teks dan pilih semua teks di kotak teks:
<textarea onfocus = "select ()"> White Dove Boy </pextarea>
<textarea onfocus = "select ()"> White Dove Boy </pextarea>
9. Pindahkan mouse ke kotak teks dan pilih semua teks di kotak teks:
<textarea onmouseover = "focus ()" onfocus = "select ()"> White Dove Boy </pextarea>
<textarea onmouseover = "focus ()" onfocus = "select ()"> White Dove Boy </pextarea>
10. Setelah masuk, fokus akan ditransfer dari kotak teks saat ini ke kotak teks berikutnya:
<TextArea OnkeyDown = ”if (event.keycode == 13) event.keyCode = 9 ″> White Dove Boy </pextArea>
<TextArea OnkeyDown = ”if (event.keycode == 13) event.keyCode = 9 ″> White Dove Boy </pextArea>
11. Setelah masuk, fokus akan ditransfer dari kotak teks saat ini ke posisi yang ditentukan:
<TextArea OnKeyPress = "Return FocusNext (ini, 'Nama ID Lokasi Tertentu', Event)"> White Dove Boy </pextarea> </span>