繁体   English   中英

显示为字符串的 HTML 标记

[英]HTML tag showing as a string

请检查我的代码,让我知道我做错了什么

 $('ul.ne.elBulletList.listSize1.listImage32.listBorder0 li').text(function(_, text) {
        // return (); // just the original requirement
        str = `<div class="heading">`;
        str += text.split('-', 1).pop();
        str += `</div><div class=text">`;
        str += text.split('-').pop();
        str += `</div>`;
        // console.dir(str));
        return innerText = str; // with whitespace removed
      });

Html 显示为纯文本。 谁能告诉我我在做什么错。

谢谢

.text( text )

我们需要注意,此方法会根据需要对提供的字符串进行转义,以便在 HTML 中正确呈现。 为此,它调用 DOM 方法 .createTextNode(),不会将字符串解释为 HTML。


.html( function )

返回要设置的 HTML 内容的函数

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM