Rendering:
Specific implementation:
1. Textarea tag content
Copy code The code is as follows:
2. Initialization allows you to enter up to 50 characters when you click the add button.
Copy code The code is as follows:
$("#introduction").val("Can enter up to 50 characters");
document.getElementById("introduction").style.color="gray";
3. js script
Copy code The code is as follows:
function getAddFocus(id){//For the add operation Introduction and remarks in, textarea gets focus and clears the input box
var textarea=document.getElementById(id);
textarea.value="";
textarea.style.color="black";
}
function lostAddFocus(id){//For the introduction and remarks in the add operation, when the textarea loses focus and the content is empty, a prompt message is displayed
var textarea=document.getElementById(id);
var textarea_value=textarea.value;
if(textarea_value==""){
textarea.value="Can enter up to 50 characters";
textarea.style.color="gray" ;
}
}
Usage reference of textarea focus written by csdn partner:
Copy code The code is as follows:
1. The text box displays the default text:
2. Click the mouse on the text box, and the default text disappears: