我已實現了以下腳本來顯示在IE輸入框用於顯示的佔位符,但它不工作密碼字段,請諮詢我..佔位符沒有在IE瀏覽器的密碼字段
<script>
jQuery(function() {
jQuery.support.placeholder = false;
test = document.createElement('input');
if('placeholder' in test) jQuery.support.placeholder = true;
});
// Placeholder for IE
$(function() {
if(!$.support.placeholder) {
var active = document.activeElement;
$(':text, textarea').focus(function() {
if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
$(this).val('').removeClass('hasPlaceholder');
}
}).blur(function() {
if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
}
});
$(':text, textarea').blur();
$(active).focus();
$('form').submit(function() {
$(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
});
}
});
</script>
看起來對於佔位符來說是非常大的代碼。你可能想要瀏覽這個[post](http://stackoverflow.com/a/19899531/1577396) –
@ T.J.Crowder對不起,我不知道,但我現在就學會了。 – alalp
我有** IE 10 **和你的代碼正在工作... –