1

placeholder没有出现在 IE9 浏览器中...在下面
提供我的代码...您是否需要为 ie9 编写任何 jquery 或 css hack

http://defie.co/contact.html

<div class="span6">
    <i class="bookmarkingContact"></i>
    <h3 style="margin-bottom: 22px;">Inquiry</h3>

    <input class="span2" type="text" name="email" placeholder="User Name">
    <input class="span2" type="text" name="email" placeholder="Company">
    <input class="span2" type="text" name="email" placeholder="Email">
    <input class="span2" type="text" name="email" placeholder="Password">
    <a href="#" style="position: relative; top: 13px;">Sign Up</a>
</div>
4

3 回答 3

5

占位符未出现在 ie9 浏览器中

IE < 10 不支持 HTML5placeholder属性。

怪癖模式

于 2013-03-09T22:01:18.427 回答
1

inputInternet Explorer 9 及更早版本不支持标记的占位符属性。所以要么使用 Javascript 来模拟效果,在输入旁边添加一个标签,要么就忘记 IE。

于 2013-03-09T22:04:03.147 回答
0

IE9 不支持。为了在 IE9 中创建相同的效果,我所做的是编写一个 JavaScript 函数来检查是否支持占位符。如果不是,则通过 jQuery 在表单元素字段中显示文本...

/*AN HTML5 INPUT ATTRIBUTE THATS REALLY COOL*/
var placeHolderSupport = ('placeholder' in document.createElement('input'));

/*IF PLACEHOLDER IS NOT SUPPORTED...*/
if(!placeHolderSupport) {

/*GET THE ID OF EACH FORM ELEMENT*/
fname       = $('#fname');
femail      = $('#femail');
furl        = $('#furl');
fcomment    = $('#fcomment');
fsubmit     = $('#sendbtn');

/*DEFINE DEFAULT VALUES FOR EACH INPUT FIELD*/
fnameval    = "Your Full Name";
femailval   = "Your E-mail Address - (It will not be shared!)";
furlval     = "Your Web Site";
fcommentval = "Your Message";



        /*ASSOCIATE THE DEFAULT VALUES TO THE FORM INPUT FIELDS*/
        fname.val(fnameval);
        femail.val(femailval);
        furl.val(furlval);
        fcomment.val(fcommentval);

        /*CYCLE THROUGH EACH INPUT FIELD TO...*/
            $.each([
            {selector: fname,   mvalue: fnameval},
            {selector: femail,  mvalue: femailval},
            //{selector: furl,    mvalue: furlval},
            {selector: fcomment,mvalue: fcommentval}
            ],function(i, obj) {

              /*...SHOW OR HIDE DEFAULT VALUES*/
                obj.selector.focus(function() {
                    if(this.value == obj.mvalue) { this.value = ''; };
                }).blur(function() {    
                    if(!this.value) { this.value = obj.mvalue;};
                });
    }
于 2013-03-09T22:09:03.290 回答