/**
* 函數:實現ie瀏覽器對placeholder的兼容
* 輸入:
* 輸出:
**/
function compatiblePlaceholder(){
var isPlaceholder = 'placeholder' in document.createElement('input');
if (!isPlaceholder) {
$("input[placeholder]").each(function() {
var text = $(this).attr("placeholder");
var $span = $('<span class="place_holder">'+ text +'</span>');
$(this).before($span);
var $that = $(this);
$span.on("click focus",function() {
$that.click();
});
$(this).click(function() {
$(this).focus();
$span.hide();
});
$(this).blur(function(){
$span.show();
});
});
$(".two_ph").each(function() {
$(this).find(".place_holder").eq(1).addClass("for_ben_rate");
});
}
}
老版本ie瀏覽器不支持placeholder功能,爲了實現該功能,有多個思路,以上是本人提供的一個思路,利用一個span標籤來模擬placeholder。