Get the App
SLTechnology News&Howtos  ›  Development  › 

How to make the placeholder genus that supports Html5 under IE

Shulou Source: shulou.com Published: 2022-06-01 11:14:39 11月16日 Update

This article will give you a detailed explanation on how to make the placeholder genus that supports Html5 under IE. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

HTML5 has made many enhancements to Web Form, such as input's new type type, Form Validation, and so on.

Placeholder is another property added to HTML5. When input or textarea sets this property, the content of the value is displayed in the text box as a gray word prompt, and the prompt text disappears when the text box gets focus. In the past, to achieve this effect can only be achieved by using JavaScript control, firefox, google chrome and so on expressed support for it, only IE has a sense of disobedience!

For example:

This paper introduces a super attribute plug-in that supports placeholder under IE, and is also compatible with other browsers that do not support placeholder. The code is as follows:

$(document) .ready (function () {

Var doc=document

Inputs=doc.getElementsByTagName ('input')

SupportPlaceholder='placeholder'in doc.createElement ('input')

Placeholder=function (input) {

Var text=input.getAttribute ('placeholder')

DefaultValue=input.defaultValue

If (defaultValue=='') {

Input.value=text

}

Input.onfocus=function () {

If (input.value===text)

{

This.value=''

}

}

Input.onblur=function () {

If (input.value==='') {

This.value=text

}

}

}

If (! supportPlaceholder) {

For (var iS0, Lenovo inputs.roomthisti

Tags: Support attributes articles code content text more tips good practical no only at the same time multiple plug-ins effects files text articles browsers Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS MariaDB Apple OPPO Reno