2012-07-13 86 views
0

我需要一些Firefox浏览器问题的帮助吗?如何在Firefox中点击输入时隐藏占位符?

我有一个占位符输入:

<input id="contact_lastname" type="text" value="" name="contact_lastname" size="45" placeholder="Type your last name" style="-moz-user-select: none; -moz-user-input: disabled; -moz-user-modify: read-only;" autocomplete="off"> 

只有在Firefox中,当我点击该输入框,占位符将消失,最后才在不可选择部分一脚是否有某种方式来禁用每次点击不可选择的输入时实际使占位符隐藏的html5事件?

我已经尝试过这些CSS值:

-moz-user-input: disabled 
-moz-user-modify: read-only 
-moz-user-select: none 
user-select: none 

我错过了一个?

回答

0

问题是不是占位符正在消失,但在点击离开时,没有回来的事实的事实。我已经改变了它实际上像这样的工作:

<script type="text/javascript"> 
$.fn.disableSelection = function() { 
     return this.each(function() { 
      if ($.browser.mozilla) // Firefox 
      { 
       $(this).attr('autocomplete', 'off'); 
       $(this).keydown(function() { return false; }); 
       $(this).css('MozUserModify', 'read-only'); 
      } 
      else if ($.browser.webkit) // Chrome 
      { 
       $(this).attr('autocomplete', 'off'); 
       $(this).css('webkitUserModify', 'read'); 
       $(this).keydown(function() { return false; }); 
      } 
      else if ($.browser.msie) // IE 
      { 
       $(this).keydown(function() { return false; }); 
      } 
      else // Opera, etc. 
      { 
       $(this).mousedown(function() { return false; }); 
      } 
     }); 
    }; 
</script> 

这实际上阻止用户输入数据,(这是原问题集),然后就解雇了keydown事件返回false。

1

在输入字段:

disabled="disabled" 
+0

或者只是“禁用”。 – robertc 2012-07-13 15:30:57

相关问题