您的位置:首页 > Web前端 > HTML

在ie9以下的版本placeholder显示

2017-09-22 16:56 204 查看
js代码: 

$(function () {

if ((navigator.appName == "Microsoft Internet Explorer") && (document.documentMode < 10 || document.documentMode == undefined)) {
var $placeholder = $("input[placeholder]");
var textArea = $("textarea[placeholder]");
for (var i = 0; i < $placeholder.length; i++) {
$placeholder.eq(i).val($placeholder.eq(i).attr("placeholder")).css({ "color": "#ccc" })
}

for (var i = 0; i < textArea.length; i++) {

textArea.eq(i).val(textArea.eq(i).attr("placeholder")).css({ "color": "#ccc" })

}
}
$placeholder.focus(function () {
if ($(this).val() == $(this).attr("placeholder")) {
$(this).val("").css({"color": "#333"})
}
})
textArea.focus(function () {
if ($(this).val() == $(this).attr("placeholder")) {
$(this).val("").css({ "color": "#333" })
}
})
});

html代码:
<input type="text" class="PDI_Job" placeholder="请输入期望职位"/>

<textarea rows="4" cols="34" placeholder="aaaaaa" ></textarea>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  html input placeholder