JSFiddle - React, Tailwind, and code Playground
HTML
<h2>title number one</h2>
<h2>and number two</h2>
CSS
ul { list-style: disc outside none }
ul li { margin-left: 20px; }
h2 { margin-bottom: 5px; font-weight: bold; font-size 20px; }
JavaScript
$(function() {
var myUL = $('<ul></ul>');
$('h2').each(function() {
var txt = $(this).text();
var href = txt.replace(/ /g, '-');
myUL.append('<li><a href="#' + href + '">' + txt + '</a></li>');
});
$('body').append(myUL);
});