html5 placeholder attribute compatible ie11

html5 placeholder attribute is an attribute for providing input field hint information describes the expected value (hint).

A simple example:

<!DOCTYPE HTML>
<html>
<body>

<form action="/test.do" method="get">
<input type="search" name="user_search" placeholder="请在此输入你的审批意见" />
<input type="submit" />
</form>

</body>
</html>

Here Insert Picture Description

The label attribute is mainly used for tips, not filled before will display when the mouse is triggered, it will hide

Here Insert Picture Description

Note: placeholder attribute applies to the following Type: text, search, url, telephone, email and password

Good, simple use of the above is the placeholder's profile, and then tell us about compatibility placeholder, the placeholder in the Chrome browser is normal, but very bad in ie compatibility.

I was ie11 tested and found placeholder, click the mouse when not hidden or displayed text.

<textarea name="handleInfo.apprIdea" id="msg" class="form-control"
                  placeholder="请在此输入您的审批意见" height="126px;" style="overflow-y: auto;" value="${handleInfo.apprIdea}">${handleInfo.apprIdea}</textarea>

Then a lot of online tutorials are rewritten style, replaced with onchange function and so on, but I think too much trouble, then found written in the debugging process $ (function () {...}); initialization function of time, add attr attribute, even It is compatible with the specific practices:

$(function(){
$("#msg").attr("placeholder","请在此输入您的审批意见");
});

Note that this method has only been tested in ie11, ie8 and so have not tested, so this blog will not be recorded

Guess you like

Origin www.cnblogs.com/mzq123/p/11366678.html