Ordered numbers in bold without adding additional tags

How to get ordered numbers in bold without adding additional tags?
Maybe in jQuery?

  •   
  • first element  
  • secondelement  
  • thirdelement

1. first element
2. second element
3. thirdelement

Regards, Hakan

+3
source share
3 answers

Assuming your sample list is a list ol, the following will do the trick.

    <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>
+7
source

You cannot select only a list item.

+2
source

, - , :

li { font-weight:bold;  }
.text { font-weight:normal !important; }


<ol>
  <li><span class="text">first element</span></li>
  <li><span class="text">secondelement<span class="text"></li>
  <li><span class="text">thirdelement<span class="text"></li>
</ol>
+2

Source: https://habr.com/ru/post/1758548/


All Articles