没有内容的文本框的jQuery克隆 [英] Jquery clone of a textbox without the content

查看:75
本文介绍了没有内容的文本框的jQuery克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以克隆一个没有内容的文本框吗?意味着如果我在克隆后在文本框中输入一些值,我想要一个空的文本框。是否可能?或者jquery clone返回此文本为innerHtml?

Can I clone one textbox without its content??Means if I enter some values in the textbox after cloning I want an empty textbox.Is it possible?Or jquery clone returns this as an innerHtml?

推荐答案

默认情况下,克隆会复制当前具有< input> 的值,但是您可以只需在克隆时清除它即可,例如:

By default, cloning copies the value with the <input> currently has, but you can just clear it when cloning, for example:

var clone = $(".myInput").clone(true).val("");

根据您的评论,克隆行时需要以下内容:

Based off your comment, you'd need something like this when cloning the row:

var newRow = $(this).closest('tr').clone(true).appendTo('table')
                                  .find('input').val('');

这篇关于没有内容的文本框的jQuery克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆