HTML5 의 Placeholder 를 지원하는 브라우저
Browsers | Placeholder Support |
IE 9 이하 | X |
Firefox 3.7 + | ✓ |
Safari 4.0 + | ✓ |
Chrome 4.0 + | ✓ |
Opera 11 | ✓ |
<input type="text" placeholder="username">
출처 : http://www.simpleeditions.com/34001/placeholder-in-html5
All you need is:
<input type="text" name="real_name" placeholder="Enter your first and last names">
Looks like this in Firefox 4.0:
The placeholder text will automatically be removed once a user clicks in or tabs to the input field. It will be restored if they tab out without having entered any text.
Don't replace the label attribute
The placeholder text is not meant to replace the <label>
element. They serve two different purposes. The <label>
should specify what to type (username, password, street address etc) whereas the placeholder attribute gives a specification on how or give examples. Like so:
<label for="subject">Subject: <input type="text" id="subject" name="subject"
placeholder="Enter a clear and descriptive subject"></label>
In Firefox:
For browsers that don't support it
This is a nice way to use HTML5 since the attribute will be ignored by browsers that don't understand it.
But if you want to make it work in other browsers, you can use some JavaScript to create the same behavior. There is an excellent jQuery plugin called HTML5 Placeholder Plugin that will go through all input fields with placeholders attached to them and make them work in all browsers.
Jquery 를 이용하여 placeholder 를 적용시키기
https://github.com/miketaylr/jQuery-html5-placeholder
jQuery-html5-placeholder-master.zip
'Story > Jquery' 카테고리의 다른 글
Multi-line Text Overflow Ellipsis (0) | 2013.08.05 |
---|---|
javascript 이용 flash param 값 변경 (0) | 2013.04.05 |
이미지 확대 효과 (돋보기 효과) JQZoom (0) | 2013.03.13 |
Regex Selector for jQuery (0) | 2013.01.22 |
Basic JQuery Selector (0) | 2012.12.31 |