Jquery 如何将括号(a)添加到有序列表中?兼容所有浏览器

Jquery 如何将括号(a)添加到有序列表中?兼容所有浏览器,jquery,css,xhtml,Jquery,Css,Xhtml,我必须表现得像 (a) (b) (c) 更新: 我找到了一个CSS方法 ol {list-style-type: none;} li:before {content: "(" counter(section, lower-alpha) ") ";} li { counter-increment: section;} 但它在IE7及更低版本中不起作用 你不能得到(a)(b)(c) 但是,您可以获得不带括号的字母: … 请参见W3C提供的 使用CSS是不可能的。您必须使用javascript(或类

我必须表现得像

(a)

(b)

(c)

更新:

我找到了一个CSS方法

ol {list-style-type: none;}
li:before {content: "(" counter(section, lower-alpha) ") ";}
li { counter-increment: section;}
但它在IE7及更低版本中不起作用

你不能得到(a)(b)(c)

但是,您可以获得不带括号的字母:

请参见W3C提供的


使用CSS是不可能的。您必须使用javascript(或类似代码)创建自定义列表。

这在自定义计数器中是可能的,但至少IE7-不支持它,其他一些也可能不支持。详情请参见此处:

例:


没有内置的方法可以做到这一点。这意味着你进入了(有趣的)黑客之地


您可以尝试使用两个括号的背景图像。

我改为创建段落。我将段落缩进,然后抽出第一行,使用文本缩进并自己编号

.list_indent {
margin-left:48px;
}
.list_indent p {
text-indent:-26px;
}

<div class="list_indent">  
<p> (1)&nbsp;&nbsp;The recruitment report and a copy of the blah and blah and blah and blah and blah and blah and blah and blah.;
</p>   
<p> (2)&nbsp;&nbsp;A copy of the blah and blah and blah and blah and blah and blah and blah and blah.
</p>     
<p> (3)&nbsp;&nbsp;Recruitment.
</p>   
</div>
.list\u缩进{
左边距:48像素;
}
.list\u缩进p{
文本缩进:-26px;
}
(1)招聘报告以及诸如此类的副本。;

(2)诸如此类的副本。

(3)招聘。


自CSS3以来,问题似乎已解决:

style="list-style-type: parenthesized-lower-latin;"

或者您可以简单地手动添加文本计数,而无需担心浏览器故障。适用于任何浏览器

ul.abc-list{
列表样式:无;
左侧填充:30px;
}
ul.abc-list>li>span.counter{
位置:绝对位置;
左边距:-20px;
/*如果要右对齐文本
* 
*宽度:15px;
*文本对齐:右对齐;
*/
}
  • a) 一个
  • b) 两个
  • c) 三
  • d) 四
  • e) 五

我在启用CSS的mediawiki中使用此代码段。我不确定这是否会在旧版本的IE中起作用


/*css处理括号/方括号*/
.laparent ol{计数器重置:项}
.laparent li{显示:块;计数器增量:项;}
/*将列表项之前的计数器替换为
开括号+计数器+闭括号*/
.laparent li:在{content:“(“计数器(项目,下阿尔法)”)”;}
  • 这是第一项,
  • 这是第二项,;或
  • 这是第三项
  • 产出:

    (a) this is the first item;
    (b) this is the second item; or
    (c) this is the third item. 
    

    我知道如何得到没有括号的字母。我问了一个问题,想知道如何添加括号。我想没有选择:(但我需要打开
    ol
    ,因为它是订购的list@jitendra然后你需要相应地更改CSS,这只是一个示例。我只是给你指出了正确的方向,你必须自己编写代码。这些是括号,不是括号。;)很好,你找到了。然而,事后改变问题并不好。这将赋予IE更多的功能,但它不包括
    计数器
    :我想你大部分运气都不好。我也在看IE7.js,但它没有显示支持:(对于
    计数器
    @Jimmy-什么?“括号”和“括号”是两个意思完全相同的词。@Hammerite-不是“完全相同的东西,”但经过进一步调查,这两个词在英国可能会互换使用:你应该格式化你的答案并描述你在做什么。这对你来说可能很简单,但你可以用几个词来解释
    
    (a) this is the first item;
    (b) this is the second item; or
    (c) this is the third item.