尝试用很少的 JS 创建一个灵活的邮件列表:
.email_item::after {
content: ", ";
}
结果:
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2f4940406f424e4643014c4042" rel="noreferrer noopener nofollow">[email protected]</a>, <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="35535a5a077558545c591b565a58" rel="noreferrer noopener nofollow">[email protected]</a>
使用 ctrl+c 和 ctrl+v 复制返回:
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2f4940406f424e4643014c40424940401d" rel="noreferrer noopener nofollow">[email protected]</a>@mail.com
我必须使用 JS 对吗?或者是否存在优化天才?
最佳答案
是的,生成的内容如 :after
和 :before
仅用于显示目的。
它不会改变 DOM,因此它是不可选择的..
为什么使用JS而不是直接在HTML中添加逗号?
Generated content does not alter the document tree. In particular, it is not fed back to the document language processor (e.g., for reparsing).
关于javascript - ctrl+c "content"来自 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13337650/