清除input中内容的简单方法

1.先写一个方法

//设置清除方法
function clearn(e) {
$(e).val("");
}

2.对应的input名字写好(我直接粘贴的我的代码可能有点乱,不过对应的东西要注意,id名和要传入的东西);

<input type="" style="outline: none; // 去除选中状态边框
background-color: rgba(0, 0, 0, 0);// 透明背景; 100%;height: 72%;border: 0;" id="names" />
</div>

<span id="clearn" style="font-size: 0.5px;" onclick="clearn('#names')">X</span>

原文地址:https://www.cnblogs.com/cai-bai/p/11772397.html