★ 2.1.2에서 해결된듯 합니다. 현재(2015년 10월 1일) 버전은 2.1.3입니다.

https://github.com/mathiasbynens/jquery-placeholder



jquery.placeholder.ls.js


ie9 이하의 브라우저에서 html5의 placeholder를 지원하는 방법으로 placeplder.js가 있고 jquery.placeholder.js가 있다.

그런데 placeplder.js는 뭔가 제대로 동작하는거 같지가 않아 jquery.placeholder.js을 선택했으나..

input type이 password인 경우 ie9는 정상작동 하지만 9미만에서는 type이 text로 바뀌지 않고 그대로 password로 유지되서

placeholder 값이 * 내지는 ●로 보여진다.

http://api.jquery.com/attr/ 여기를 읽어보니 이런 내용이 있네?

Note: Attempting to change the type attribute (or property) of an input element created via HTML or already in an HTML document will result in an error being thrown by Internet Explorer 6, 7, or 8.

처리되는 부분은 2.1.0버전 기준 162라인

$replacement = $input.clone().attr({ 'type': 'text' });

이것인데 원래의 input을 복사해다가 type만 text로 바꾼다는 내용이지만 ie6,7,8에서는 type이 이미 명시된 경우에는 바뀌지가 않는다는..걸로 해석하면 맞으려나?

그래서

	if($.browser.msie && $.browser.version<=9) {
		$replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
	}

이걸 추가해보니 동작은 정상적으로 되지만 속성을 보니 class가 두개가 잡힌다.

뭐 문제는 없겠으나 행여나 오작동 할 여지가 있어보여 다시 수정했다.

	if($.browser.msie && $.browser.version<=9) { // less then ie9. 2015.02.17.dusthand.
		$replacement = $('<input>').attr({ 'type': 'text' });
		$.each(args(this), function(a_name,a_value){
			if(a_name=='type' || a_name=='') return true;
			if(a_name=='class')
				$replacement.addClass(a_value);
			else
				$replacement.removeAttr(a_name).attr(a_name,a_value);
		});
	}

이렇게 추가해서 해결.

참고로 jquery버전은 1.11.1 이고 migrate-1.2.1도 로딩했다.

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>


'jQuery' 카테고리의 다른 글

lazyload 플러그인. 일부만 안보여?  (0) 2014.11.14
블로그 이미지

먼지손

,

저런 어이없는 현상이 발생하는 이유까진 모르겠고..

css에서 overflow:visible; 해주시면 해결이 된다..;

여차하면 기본(tags reset해주는 css쪽)에

button, input[type=button], input[type=submit] {overflow:visible;}

이렇게 추가해주면 좋지 않을까 싶기도..

아니면 ie7만 적용되시라는 핵이 언더바였던가 스타였던가;;

난 그냥 6,7 같이 쓰는 #overflow:visible; 로 처리.. (에혀 익스 진짜...)

블로그 이미지

먼지손

,