input-placeholder gets focus and clears

In html, placeholder, as an attribute of input, plays the role of occupying and prompting in the input box.

However, in some browsers, such as chrome, when the mouse clicks the input box, the value of the placeholder does not disappear, only the input data disappears, which will greatly reduce the front-end user experience.

After reading a lot of God's methods, writing a long js, and looking a little hard, I thought of the stupidest method below to solve this problem.

HTML code:

<input type="text" placeholder="Please input">
Just add two short js in it:

<input type="text" placeholder="Please enter" onfocus="this.placeholder= ''" onblur="this.placeholder='Please enter'">

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326591939&siteId=291194637