在IE8中如何解决placeholder的兼容问题?


问题详情: 想实现在搜索框中开始有文字,当点击之后文字消失的效果。之前用的都是HTML5中的placeholder属性,但是在IE8中改属性用不了。

在其他地方搜索答案,都是通过js来解决的,感觉比较麻烦,有没有其他的解决办法?直接利用css hack可以解决吗?或者说 <input type="text" value=" "/> 采用value的方式?

ie8兼容性 ie8 placeholder html5

三重快意男儿 9 years, 5 months ago

用js就挺好,哪里会麻烦,有写好的插件。 Placeholders.js

农妇山泉有点田 answered 9 years, 5 months ago

<span>placeholder</span> <input type='text' /> 通过css就行了

synan answered 9 years, 5 months ago


 <input type="text" onblur="if (this.value == '') {this.value = 'Search';}" onfocus="if (this.value == 'Search') {this.value = '';}" value="Search" >

demo

灼眼D天使 answered 9 years, 5 months ago

Your Answer