Javascript HTML中的emptyText

Javascript HTML中的emptyText,javascript,html,extjs,Javascript,Html,Extjs,有没有办法在输入字段中像在ExtJS中一样有类似于emptyText的内容 我尝试用更改的CSS设置值。但是,该值随表单一起提交,并且在单击输入字段时不会立即消失。我需要支持IE7及以上版本 任何帮助都将不胜感激。您正在寻找的是占位符 Rajat的答案是正确的,但仅适用于HTML5。 你可以看看你是否想要一个能在IE(和其他浏览器)上运行的答案只使用纯javascript而不使用任何库这是哪个浏览器的?我正在使用IE,没有看到任何空文本/占位符文本。检查这个在IE10和更好的版本中工作,它在IE

有没有办法在输入字段中像在ExtJS中一样有类似于emptyText的内容

我尝试用更改的CSS设置值。但是,该值随表单一起提交,并且在单击输入字段时不会立即消失。我需要支持IE7及以上版本


任何帮助都将不胜感激。

您正在寻找的是
占位符


Rajat的答案是正确的,但仅适用于HTML5。
你可以看看你是否想要一个能在IE(和其他浏览器)上运行的答案只使用纯javascript而不使用任何库

这是哪个浏览器的?我正在使用IE,没有看到任何空文本/占位符文本。检查这个在IE10和更好的版本中工作,它在IE9和belowYep中不工作。刚刚检查了链接:(不幸的是,我需要在IE7及以上版本中使用它:(@hop,网上有很多脚本添加了IE7+支持。
<input type="text" placeholder="Hii" />
// This adds 'placeholder' to the items listed in the jQuery .support object. 
jQuery(function() {
   jQuery.support.placeholder = false;
   test = document.createElement('input');
   if('placeholder' in test) jQuery.support.placeholder = true;
});


// This adds placeholder support to browsers that wouldn't otherwise support it. 
$(function() {
   if(!$.support.placeholder) { 
      var active = document.activeElement;
      $(':text').focus(function () {
         if ($(this).attr('placeholder') != '' && $(this).attr('placeholder') != undefined && $(this).val() == $(this).attr('placeholder')) {
            $(this).val('').removeClass('hasPlaceholder');
         }
      }).blur(function () {
         if ($(this).attr('placeholder') != '' && $(this).attr('placeholder') != undefined && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
            $(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
         }
      });
      $(':text').blur();
      $(active).focus();
      $('form:eq(0)').submit(function () {
         $(':text.hasPlaceholder').val('');
      });
   }
});