在ie9以下的版本placeholder顯示

js代碼: 

$(function () {
            
            if ((navigator.appName == "Microsoft Internet Explorer") && (document.documentMode < 10 || document.documentMode == undefined)) {
                var $placeholder = $("input[placeholder]");
                var textArea = $("textarea[placeholder]");
                for (var i = 0; i < $placeholder.length; i++) {
                    $placeholder.eq(i).val($placeholder.eq(i).attr("placeholder")).css({ "color": "#ccc" })
                }

                for (var i = 0; i < textArea.length; i++) {

                    textArea.eq(i).val(textArea.eq(i).attr("placeholder")).css({ "color": "#ccc" })

                }
            }
            $placeholder.focus(function () {  
                if ($(this).val() == $(this).attr("placeholder")) {  
                    $(this).val("").css({"color": "#333"})  
                }  
            })
            textArea.focus(function () {
                if ($(this).val() == $(this).attr("placeholder")) {
                    $(this).val("").css({ "color": "#333" })
                }
            })
        });

html代碼:

<input type="text" class="PDI_Job" placeholder="請輸入期望職位"/>

<textarea rows="4" cols="34" placeholder="aaaaaa" ></textarea>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章