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>