Reputation: 1248
I want to replace the span tag with another tag but when i empty out the tag it also erase's the span tag. i want to implement the span tag back in as well as the new content that goes in it. any help would be greatly appreciated, thank you.
The basic question is how do i add a span tag with in a jQuery object string
FYI, i am just adding the appropriate script so that you can see the basic idea of what i am trying to. i know that the code wont work based on what i posted. too long of code to add.
javascript code:
var UxDesign = new Object();
UxDesign.h1 = "HELLO |" + <span>eHello</span>"";
content.find('h1').empty();
h1Text.text(UxDesign.h1);
html code:
<h1>Interactive | <span>eDetail</span></h1>
SO CURRENTLY when i view it in the browser it comes up like this:
HELLO |<span>eHello</span>
when i am wanting it to show like this
HELLO | eHello
I have the span tag in their cause i have two separate fonts being shown.
Upvotes: 0
Views: 74
Reputation: 5985
I would simply change a couple of things:
first, your variable UxDesign.h1
should = "hello | <span>eHello</span>";
So keep it all in the same quotes.
After you empty your h1
, you need to update the HTML inside of it by using .html()
instead of .text()
:
h1Text.html(UxDesign.h1);
Upvotes: 1