<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div style="width: 60px; margin: 0 auto"> <input id='i1' type="text" value="请输入内容" onfocus="Focus()" onblur="Blur()"> </div> <script> function Focus() { tag = document.getElementById('i1'); val = tag.value; if (val == '请输入内容') { tag.value = ''; } } function Blur() { tag = document.getElementById('i1'); val = tag.value; if (val.length==0){ tag.value = '请输入内容'; } } </script> </body> </html>