日期:2014-05-16 浏览次数:20450 次
<style>
.input{position:relative;}
.input .x{display:none;text-decoration:none;position:absolute;left:190px;color:blue;font-weight:bold}
</style>
<div class="input"><a href="#" class="x" onclick="return clearInput(this)">x</a><input type="text" style="width:200px" onkeyup="xShow(this)" /></div>
<script type="text/javascript">
function clearInput(a) {
a.parentNode.getElementsByTagName('input')[0].value = '';
a.style.display = 'none';
return false;
}
function xShow(ipt) {
ipt.parentNode.getElementsByTagName('a')[0].style.display = ipt.value == '' ? 'none' : 'block'
}
</script>