PlaceHolder属性在Internet Explorer中不起作用 [英] PlaceHolder attribute is not working in Internet Explorer

查看:92
本文介绍了PlaceHolder属性在Internet Explorer中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,亲爱的朋友,
我正在尝试在我的网站中使用占位符属性.

我正在针对IE使用此脚本
它有效,但仅适用于输入文本.

Hello My Dear Friends,
I am trying to use placeholder attribute in my website.

i am using this script for IE
it works but only for input text.

<script type="text/javascript">
    $(function() {
        if (!$.support.placeholder) {
            var active = document.activeElement;
            
            $(':text').focus(function() {
                if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
                    $(this).val('').removeClass('hasPlaceholder');
                }
            }).blur(function() {
                if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
                    $(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
                }
            });
            $(':text').blur();
         
            $(active).focus();
           
           
            
        }
    });
</script>




我希望使用占位符作为密码&还可以是textarea....
请帮助...!




I want placeholder for password & textarea also....
Please Help...!

推荐答案

(函数(){ 如果(!
(function() { if (!


.support.placeholder){ var active = 文档 .activeElement;
.support.placeholder) { var active = document.activeElement;


(' :text').focus( function () { 如果(
(':text').focus(function() { if (


这篇关于PlaceHolder属性在Internet Explorer中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆