gpt4 book ai didi

jquery - 如何使用 jquery 使此 css 代码(计数器和;之前)跨浏览器兼容?

转载 作者:行者123 更新时间:2023-11-27 22:35:58 25 4
gpt4 key购买 nike

如何使用 jquery 使此 css 代码跨浏览器兼容。此代码仅适用于 firefox 和 IE8。我也想在 IE6 和 7 中使用。

ol {list-style-type: none;}
li:before {content: "(" counter(section, lower-alpha) ") ";}
li { counter-increment: section;}

这是html

<ol class"fnotes">    
<li> item 1 </li>
<li> item 2 </li>
<li> item 3 </li>
</ol>

我需要这个输出

(a) 元素 1

(b) 元素 2

(c) 元素 3

最佳答案

你可以这样做:

$(function() {
$("li").each(function(i) {
$(this).prepend("(" + String.fromCharCode(i + 97) + ") ");
});
});

注意:26 个字符限制:)

以防万一有人需要疯狂的兴奋,这从 (a)(zz) 正确,应该有很多脚注......

$("li").each(function(i) {
var prefix = "";
if(i >= 26) {
prefix = String.fromCharCode((i / 26 + 96));
i = (i % 26)
}
$(this).prepend("(" + prefix + String.fromCharCode(i + 97) + ") ");
});​​​

关于jquery - 如何使用 jquery 使此 css 代码(计数器和;之前)跨浏览器兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2558686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com