I've been trying to use jquery to apply a function to each html tag with some class inside a html object (imported from a file), but I can't get it to work. I've looked through several other questions on SE but couldn't find a solution to my problem.
The html variable contains much more code in my actual use case, but this
html = '<pre class = "classy"> text </pre>'
$(html).find('.classy').each( function (x) {
$('<pre class = "classy">' + '<h1>' + x + '<h1>' + '</pre>')
})
'<pre class = "classy"> text </pre>'
where the intended output was more like
'<pre class = "classy"> <h1> text </h1> </pre>'
.replaceWith didn't work either, so I presume I'm doing something conceptually wrong. Any solutions/tips?