如何使用jQuery从字符串中删除输入标签?此字符串还包含其他html标签

这是字符串:

您好&nbsp;<input type="text" placeholder="Person&nbsp;Full&nbsp;Name">,<span><br></span><span><br></span><span><span>,这是&nbsp;</span></span><input type="text" placeholder="Deal&nbsp;Title">&nbsp;&nbsp;<input type="text" placeholder="Deal&nbsp;Owner"><span><br></span><span><br></span><span><span><br></span></span><span><span><span>相关的</span></span></span><span><span><span><span><br></span></span></span></span><input type="text" placeholder="Organization&nbsp;Name"><span><br></span><span> dlkgmffkgmkm &nbsp;</span><input type="text" placeholder="">&nbsp; dslkfmlgdmglkfnkl <input type="text" placeholder=""><br>

我也在我的文本区域中使用编辑器。

        $(".btn-removehtml").click(function() {
           html = $('.email-textarea').Editor("getText");
           replaceInput = html.find('input').replaceWith(function() {
                return this.innerHTML;
           }).end().html();
        });
tonghai0709 回答:如何使用jQuery从字符串中删除输入标签?此字符串还包含其他html标签

您可以尝试一下。

var string = '<input type="text" placeholder="Person&nbsp;Full&nbsp;Name">,<span><br></span><span><br></span><span><span>';

var newString = $(string).not('input');

$('body').append(newString);

对于所有用途的输入,您都可以这样做。

var newString = $(string).find('input').remove().end();
,

调用下面的函数将所有输入替换为静态值“ abcd”


function parseEmailTemplate(html) {
    let myRegex = /<input\s[^>]*>/gi;
    let match = myRegex.exec(html);
    if (match) {
        value="abcd";
        html = html.replace(match[0],value);
        html = parseEmailTemplate(html);
    }
    return html;
}

本文链接:https://www.f2er.com/3161603.html

大家都在问