2012-01-27 4 views
2

이 스크립트를 사용하여 http://www.morethannothing.co.uk/wp-content/uploads/2010/01/placeholder.js IE에 일부 자리 표시자를 가져옵니다. 텍스트 및 암호의 입력 유형에 대한 대우를 수행합니다.IE의 자리 표시 자

하지만 텍스트 영역에는로드되지 않는 것 같습니다. 누구든지 내가 추가 할 수있는 코드 줄을 알고 있거나로드하기 위해 실행할 수있는 jQuery 또는 JavaScript 약간을 maybes.

미리 감사드립니다.

+2

의 jQuery 틀 플러그인 다임 다스있다 'textarea'를 직접 지원하는 것으로 전환하고 싶을 수도 있습니다. 이 모든 작업은 : [place5] (http://code.google.com/p/place5/) (광산), [jquery-placeholder] (https://github.com/mathiasbynens/jquery-placeholder), [jquery -placeholder (2)] (https://github.com/danielstocks/jQuery-Placeholder) –

+0

동의 함. 자리 표시 자 플러그인은 매우 유용하며 유용합니다. – StuBlackett

답변

1

대신 $(':text[placeholder],:password[placeholder]') 사용 $(':text[placeholder],:password[placeholder],textarea[placeholder]') 모든 입력 및 텍스트 영역 용

+1

브라우저의 * fast *, 네이티브 선택기 엔진을 사용하는 대신에, Sizzle이 모든 것을 처리해야하기 때문에': text',': password' 또는 다른 jQuery의 선택자를 사용해서는 안됩니다 (도움이된다면). 이 경우 반복되는 작업 자체 - DOM의 모든 요소. –

0

: $ ('입력 [자리, 텍스트 영역 [틀])

0
<script type="text/javascript"> 
    if(navigator.userAgent.indexOf("MSIE") > 0) 
    { 
     $(function() 
     { 
      var input = document.createElement("input"); 
      if(('placeholder' in input) == false) 
      { 
       $('[placeholder]').focus(function() 
       { 
        var i = $(this); 
        if(i.val() == i.attr('placeholder')) 
        { 
         i.val('').removeClass('placeholder'); 
         if(i.hasClass('password')) 
         { 
          i.removeClass('password'); this.type='password'; 
         } 
        } 
       }).blur(function() 
       { 
        var i = $(this); 
        if(i.val() == '' || i.val() == i.attr('placeholder')) 
        { 
         if(this.type=='password') 
         { 
          i.addClass('password'); this.type='text'; 
         } 
         i.addClass('placeholder').val(i.attr('placeholder')); 
        } 
       }).blur().parents('form').submit(function() 
       { 
        $(this).find('[placeholder]').each(function() 
        { 
         var i = $(this); 
         if(i.val() == i.attr('placeholder')) i.val(''); 
        }); 
       }); 
      } 
     }); 
    } 


    </script>