我知道 IE7 有问题...
我在这里和 Google 上阅读了一些帖子,告诉我需要手动设置样式 onfocus() 和 onblur()。但是,我尝试的一切都不起作用!
这是我的 jQuery
$(document).ready(function(){
if (jQuery.browser.msie === true) {
$("input.date-picker").each(function(i)
{
var $foo= $(this);
$foo.bind('onfocus onblur', function() {
$(this).toggleClass('smalltxt-active');
});
});
}//end if
});
一个对应的框
<input name="ctl00$SelectionContent$Selections1$txtDestinationDate" type="text"
id="ctl00_SelectionContent_Selections1_txtDestinationDate" class="date-picker"
style="width:80px;" />
我已经确认我的代码正在检测 MSIE。我得到了 2 个 input.date-picker 对象的计数。
有什么想法吗?
提前致谢
最佳答案
$foo.bind('onfocus onblur', function() {
应该是
$foo.bind('focus blur', function() {
你真的不需要每个循环,
$("input.date-picker").bind('focusin focusout', function(){
$(this).toggleClass('smalltxt-active');
}
刚刚好。它将选择所有具有“日期选择器”类的输入元素并将事件绑定(bind)到它。 您可能还想阅读有关 .focusin() 的信息和 .focusout()事件。
关于asp.net - IE7中焦点如何改变输入框的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2941683/