有序数字加粗而不添加更多标签

Hak*_*eni 3 html css jquery

如何在不添加更多标签的情况下获得有序数字粗体?
在jQuery中可能吗?

  1. 第一要素
  2. secondelement
  3. thirdelement

1.第一元素
2. secondelement
3. thirdelement

最好的问候
hakan

Mik*_*son 7

假设您的样本列表是一个ol列表,以下将执行此操作.

    <html>
    <head>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js" />
        <script type="text/javascript">
            $(document).ready(function () {
                $("ol li").each(function (index) {
                    $(this).wrapInner("<span />");
                });
                $("ol").css("font-weight", "bold");
                $("ol li span").css("font-weight", "normal");
            }
            );
        </script>
    </head>
    <body>
        <ol>
            <li>first element</li>
            <li>secondelement</li>
            <li>thirdelement</li>
        </ol>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)