Convert string to plain text id
$('.field h2, .field h3').each(function() { var t = $(this); var id = t.text().replace(/[^\w\s]/gi, '').replace(/\s+/g, '').toLowerCase(); t.attr('id',id); });