代码之家  ›  专栏  ›  技术社区  ›  TheGeekYouNeed

如何更改IE7中焦点输入框的样式?

  •  0
  • TheGeekYouNeed  · 技术社区  · 16 年前

    我知道IE7有问题。。。

    我在这里和Google上都读过帖子,告诉我需要手动设置样式onfocus()和onblur()。然而,我尝试的一切都不起作用!

        $(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对象。

    有什么想法吗?

    2 回复  |  直到 16 年前
        1
  •  3
  •   jAndy    16 年前
    $foo.bind('onfocus onblur', function() {
    

    应该是

    $foo.bind('focus blur', function() {
    

    $("input.date-picker").bind('focusin focusout', function(){
      $(this).toggleClass('smalltxt-active');
    }
    

    一切都很好。它将使用类“date picker”选择所有输入元素,并将事件绑定到它。 您可能还想了解 .focusin() .focusout() 事件。

        2
  •  0
  •   Ranga Pathmasiri    15 年前

    $(this.toggleClass('focu'); });

    推荐文章