Javascript 无法从字符串集合中找到href标记

Javascript 无法从字符串集合中找到href标记,javascript,jquery,Javascript,Jquery,这是我的密码 $(lines[i]).find('[href]').each(function () { checkLinkFooter = true; footerLinks += $(this).attr('href') + '~'; }); And my string is : If you prefer not to receive, reply to the sender or

这是我的密码

   $(lines[i]).find('[href]').each(function () {
        checkLinkFooter = true;
        footerLinks += $(this).attr('href') + '~';
        });                   And my string is : If you prefer not to receive, reply to   the sender or        contact us at <a target="_blank" href="mailto:tmcustomerresponse@agi.com" style="font-weight:bold;text-decoration:none;color:#0085d5">tmcustomerresponse@agi.com</a>. Getting console error " Syntax error, unrecognized expression:"
$(行[i])。查找('[href]')。每个(函数(){
checkLinkFooter=true;
footerLinks+=$(this.attr('href')+'~';
});                   我的字符串是:如果您不想接收,请回复发件人或与我们联系。获取控制台错误“语法错误,无法识别的表达式:”

您需要使用另一个dom对象来包装字符串


现在你有一个字符串从一个单词开始,所以jQuery会把它看作一个选择器,但是因为它包含无效字符,它可能会抛出一个错误,比如说“代码> un谬误:语法错误,未被识别的表达式:Hi

< p>你需要用另一个DOM对象来包装你的字符串。
现在你有一个从一个单词开始的字符串,所以jQuery会把它看作一个选择器,但是因为它包含了无效字符,它可能会抛出一个错误,比如说“代码> un谬误:语法错误,未被识别的表达式:Hi

尝试行[i],而不是$(行[i]),在字符串中有HTML,不过编辑器刚刚删除了它。C-link:这是jquery的完美用法。它将返回一个jquery感知数组的对象。请确保find[href]是否真的适合您的需要。要么你想找到a标记并获得.attr('href'),要么你想找到href属性,但你不会在href-ATTRIBUTE中有.attr('href')。试试lines[i]而不是$(lines[i])字符串中有HTML,但编辑器只是删除了它。C-link:这是jquery的完美用法。它将返回一个jquery感知数组的对象。请确保find[href]是否真的适合您的需要。要么你想找到a标记并获得.attr('href'),要么你想找到href属性,但在href-ATTRIBUTE中没有.attr('href')。它是新div的innerHTML属性的值element@win然后接受答案,在这里您将看到右符号。它是新div的innerHTML属性的值element@win然后接受答案,你会看到右边的标志。
$('<div />', {
    html: lines[i]
}).find('[href]').each(function () {
    checkLinkFooter = true;
    footerLinks += $(this).attr('href') + '~';
});