gpt4 book ai didi

javascript - IE9 的占位符脚本默认情况下不起作用。但在离开输入后工作

转载 作者:行者123 更新时间:2023-11-28 06:12:13 25 4
gpt4 key购买 nike

对于 IE 9 浏览器,我启用了输入占位符文本。当页面登陆时,它不显示占位符文本。但在我离开输入后它就起作用了。我缺少一些东西。

你能帮我吗

我的脚本是

// Initialize inline labels for IE
if ($.browser.msie)
{
alert('i m iE')
$("input[name='firstname']").each(function() {
$(this).addClass("inlineLabel");
});
$("input[name='lastname']").each(function() {
$(this).addClass("inlineLabel");
});
$("input[name='email']").each(function() {
$(this).addClass("inlineLabel");
});
$("input[name='address']").each(function() {
$(this).addClass("inlineLabel");
});
$("input[name='dayphone']").each(function() {
$(this).addClass("inlineLabel");
});
$("input[name='zip']").each(function() {
$(this).addClass("inlineLabel");
});
$("input[name='city_temp']").each(function() {
$(this).addClass("inlineLabel");
});
initLabels();
}

// Inline labels
function initLabels() {
$("input.inlineLabel").each(function() {
var l = $(this).attr("placeholder");
this.value = l;
$(this).addClass('unfilled');
});
$('input.inlineLabel').focus(function() {
var l = $(this).attr("placeholder");
if (this.value == l)
$(this).val('').removeClass('unfilled');
});
$('input.inlineLabel').blur(function() {
var l = $(this).attr("placeholder");
if (this.value == '') {
this.value = l;
$(this).addClass('unfilled');
}
});
}

最佳答案

尝试将 this.value 替换为 $(this).val() 以获取输入值,并使用 $(this).val(your_value) 设置,就像您已经做的那样

关于javascript - IE9 的占位符脚本默认情况下不起作用。但在离开输入后工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36277186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com