Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make the placeholder genus that supports Html5 under IE

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report