You are so close!
Your html string is not valid (require close tag, "
for class name).
The .find('span.name')
function return "nothing", because span
now is root and the root element just has a text node (mytext
).
Just wrap you span
into a div
object, then do as you do to access to your span
element. In this case you append style attribute for the element.
const myDiv = `<span class="name">mytext</span>`; // I corrected you html string
const $ele = $('<div>').append(myDiv); // wrap your html string into a div element, now div is root
$ele.find('span.name').css('font-size', '3px'); // append style attr
const html = `<div>${$ele.html()}</div>`; // html() mean inside html string (inside div)