js实现placeholder效果

IE对placeholder的支持不好,一直到IE11才对其支持,那之前版本怎么办呢?这里就给出来一个简单易行的方案。

<input type="text" vtype="required" id="searchitem" 
<{if $data.searchitem}>value="<{$data.searchitem}>" style="color: black;"
<{else}>value="输入商品名称" style="color: gray;"<{/if}> 
onblur="if(this.value==''){this.value='输入商品名称',this.style.color='gray'}" 
onfocus="if(this.value=='输入商品名称'){this.value='',this.style.color='black'}">


猜你喜欢

转载自blog.csdn.net/beauty5188/article/details/80801724