js代码
<script type="text/javascript"> document.getElementById("search").addEventListener("keyup",function(){ if(this.value.length>0) { document.getElementById("cls").style.visibility="visible"; document.getElementById("cls").onclick=function() { document.getElementById("search").value=""; } }else { document.getElementById("cls").style.visibility="hidden"; } }); </script>