<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<style rel="stylesheet" type="text/css">
.clear {
display: none;
position: absolute;
width: 21px;
height: 21px;
background: url(img/add.png);
}
.input::-ms-clear {
display: none;
}
.input:valid + .clear {
display: inline;
}
</style>
<div class="recharge_detail">
<input class="input" id="input" placeholder="请输入..." required>
<i class="clear" onclick="cleared()"></i>
</div>
<script>
function cleared() {
var tag = document.getElementById("input").value;
if (tag) {
document.getElementById("input").value = '';
}
}
</script>
</body>
</html>