Home >Web Front-end >JS Tutorial >jQuery implements HTML5 placeholder effect example_jquery
You must know the new placeholder attribute in HTML5, right? It doesn’t matter if you don’t know. If the input box has default text, such an effect is often needed. Click to make the default text disappear, and make the default text appear after losing focus.
Today I share a piece of jQuery code to simulate the placeholder effect.
Javascript code:
Html code:
Some people may ask, since HTML5 provides such functions, why write JS?
Isn’t this nonsense? Of course it’s a compatibility issue. If IE was more compatible with HTML5, who would be willing to use js to implement this thing?