如何获取以列表样式类型声明的列表项(< li>)标记/标签? [英] How to get list item (<li>) marker/label declared in list-style-type?

查看:188
本文介绍了如何获取以列表样式类型声明的列表项(< li>)标记/标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < ul style =list-style-type:upper-拉丁;> 
< li> Lorem< / li>
< li> Ipsum< / li>
< / ul>

list-style-type may be任何 - 上罗马,片假名,下希腊语)



list-style-type:upper-latin; 会在每个列表项前面放一个字母(从A开始)。
有没有办法让任何给定的列表项目的这封信?我可以使用jQuery迭代列表 .index() 或类似的。



或者,也许有办法从样式中提取标记?



回答此处仅适用于拉丁字母表。 / p>

解决方案


有没有办法让任何给定列表项目的这封信?


是的。您可以阅读列表样式类型并生成每种样式类型显示的字符。然而,对于特定的商品编号和样式类型显示的字符可能因浏览器而异。


或者,也许有办法从风格?


没有。 (至少不是现在的)



一些用于编写生成器的有用内容:



另外,许多列表样式都是其他列表样式的大写版本。可以很好地知道,那么 myString.toUpperCase()也适用于unicode字符。 :)

Lets say I have a list like this:

<ul style="list-style-type: upper-latin;">
  <li>Lorem</li>
  <li>Ipsum</li>
</ul>

(list-style-type might be anything - upper-roman, katakana, lower-greek)

list-style-type: upper-latin; will put a alphabet letter (starting from A) in front of every list item. Is there a way to get this letter for any given list item? I can probably iterate over list using jQuery .index() or similar.

Or, maybe there is way to extract markers from style?

The answer here works only for Latin alphabet lists.

解决方案

Is there a way to get this letter for any given list item?

Yes. You can read the list-style-type and generate what characters are showing for each style type. Which character is shown for a specific item number and style type could vary across browsers though.

Or, maybe there is way to extract markers from style?

No. (At least not currently)

Some useful stuff for writing a generator:

Also, many of the list-styles are uppercase versions of other list styles. Could be good to know then that myString.toUpperCase() works on unicode characters as well. :)

这篇关于如何获取以列表样式类型声明的列表项(&lt; li&gt;)标记/标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆