<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 8 年前。
标签 javascript jquery html css
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 8 年前。
我创建了以下文本输入:
<input type="text" class="signup-input text-value" name="" placeholder="e.g. example@url.com">
我必须实现一个删除功能(在输入的末尾显示一个“x”图标)。
最佳答案
您可以将 type
设置为 search
:
<input type="search" class="signup-input text-value" name="" placeholder="e.g. example@url.com">
type="search"
将在输入中添加一个 x
按钮,单击该按钮会删除内容。
fiddle -> http://jsfiddle.net/rnfp59jg/
现代浏览器对 type="search"
的支持,来自 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input :
Feature Chrome Firefox (Gecko) IE Opera Safari
type=search 5.0 4.0 (2.0) 10 11.01 (Yes)
关于javascript - 如何在文本输入中插入删除图标并实现删除文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28340633/
相关文章:
javascript - JavaScript 测试的 Jenkins 测试覆盖率报告
javascript - 在 KnockoutJS 中为 jQuery 插件创建自定义绑定(bind)
javascript - fancybox2 的问题 - $.fancybox.resize 不是函数 - 错误
javascript - 从具有多个父子的嵌套 Json 获取特定数据
java - 如何为 JODConverter 2.2 指定 DocumentFormat
javascript - 使用 Chrome 控制台的参数运行自定义函数
javascript - 即使在获取数据后,React 组件的 render 方法也会调用两次