使用 div 的值附加输入文本字段 [英] Append input text field with value of a div

查看:10
本文介绍了使用 div 的值附加输入文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将输入文本字段及其值附加为 div 的值.

I'm trying to append an input text field and its value to be the value of a div.

到目前为止,这是我想出的:

Here is what I came up so far:

$(this).append('<input type="text" value=' $('#div1').val() '>');

推荐答案

不要对所有内容都使用 HTML 字符串!

Don't use HTML strings for everything!

$(this).append(
    $('<input>', {
        type: 'text',
        val: $('#div1').text()
    })
);

这篇关于使用 div 的值附加输入文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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