Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net HTML输入文本框占位符在Visual Studio环境之外不起作用_Asp.net_Visual Studio 2010_Internet Explorer - Fatal编程技术网

Asp.net HTML输入文本框占位符在Visual Studio环境之外不起作用

Asp.net HTML输入文本框占位符在Visual Studio环境之外不起作用,asp.net,visual-studio-2010,internet-explorer,Asp.net,Visual Studio 2010,Internet Explorer,我有一个html输入文本框,其中包含文本,当用户点击该框时,文本将消失。当在VisualStudio(2010)中使用IE10和IE11进行开发时,这一切都非常有效。但是,当我部署到live站点时,占位符中的文本不再可见?我认为这是因为VS运行在一个不同的模式或类似的东西,但如何才能让它的工作时,该网站只是由IIS运行 <input name="query" type="text" id="search_input" placeholder="Search on Client Name o

我有一个html输入文本框,其中包含文本,当用户点击该框时,文本将消失。当在VisualStudio(2010)中使用IE10和IE11进行开发时,这一切都非常有效。但是,当我部署到live站点时,占位符中的文本不再可见?我认为这是因为VS运行在一个不同的模式或类似的东西,但如何才能让它的工作时,该网站只是由IIS运行

<input name="query" type="text" id="search_input" placeholder="Search on Client Name or   Code"/>

也许您可以尝试一下,看看它是否在两个地方都有效:

<input id="example-email" type="text" value="Email Address" onfocus="if(this.value === 'Email Address') this.value = '';" onblur="if(this.value === '') this.value = 'Email Address';" name="example-email">

下面是我正在使用的一个简单的jQuery替代方案。这将查找任何具有
占位符属性的元素,并切换占位符的输入和输出

HTML

<input name="query" type="text" id="search_input" placeholder="Search on Client Name or Code"/>

IE与在VS for HTML5容器中运行有所不同。搜索结果显示了相互矛盾的答案。您好-是的,另一种方法也同样有效。非常感谢。非常感谢!它本质上就是“占位符”的作用。
$('[placeholder]').on('focus', function () {
    if ($(this).val() == $(this).attr('placeholder')) {
        $(this).val('');
        $(this).css('color', '#000000');
    }
});
$('[placeholder]').on('blur', function () {
    if ($(this).val() == '') {
        $(this).css('color', '#A9A9A9');
        $(this).val($(this).attr('placeholder'));
    }
}).trigger('blur');