Using the jQuery function .before(), I am creating an element in this format:
d.children().first().before("<div class='test-div'><span class='test-span'>" + text + "</span></div>")
I want to style the span dynamically by adding a variable pixel count using something like this:
"...style='"left" + leftOffset'..."
However, due to the double quotes (" ") requirement of the .before() function, this approach is not working. Trying to use .style() after .before() results in an error:
Uncaught TypeError: d.children(...).first(...).before(...).style is not a function
Is there a way to solve this issue that I'm overlooking, or do I need to apply the style differently?
Some suggested this was a duplicate question, but the linked question deals with a different scenario. In my case, it's not about escaping single quotes but rather using a third pair of quotes within two pairs.