我希望在每个文本框前面这样的清除按钮来清除它的文本。您可以在中看到这种类型的清除按钮。但这是IE的默认功能。
我只能使用CSS、HTML和JAVASCRIPT。不幸的是,我不能使用Jquery。那么有什么方法可以做到吗?
谢谢

发布于 2014-08-03 14:23:04
演示
javascript
document.getElementById('inputClear').onclick = function () {
document.getElementById('inputText').value = "";
};html
<span class="deleteicon">
<input id="inputText" value="input here" type="text" />
<span id="inputClear"></span>
</span>css
span.deleteicon {
position: relative;
}
span.deleteicon span {
position: absolute;
display: block;
top: 4px;
right: 4px;
width: 16px;
height: 16px;
background: url('http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=4') 0 -690px;
cursor: pointer;
}
span.deleteicon input {
padding-right: 20px;
}https://stackoverflow.com/questions/25105528
复制相似问题