I am trying to replace text within an element on the fly, however .text() function is replacing both text and HTML. Any thoughts on how I only edit the actual text?
<div>
<h3 class="titleHeading">My Title <a ng-click="openTooltip('getMoreInfo')"><span class="toolTip"></span></a>
<div>
I want to change the words "My Title" to "My New Title", however whenever I use .text() function, it replaces all of my html and my anchor tag disappears.
Here is my jQuery:
$('h3.titleHeading').text("My New Title")
My output is then - again, the code removes my anchor tag which I need for a tooltip.
<div>
<h3 class="titleHeading">My New Title
<div>
h3element should be closed, perhaps that's why you're confused by what is happening.<h3 class="titleHeading">My Title <a ng-click="openTooltip('getMoreInfo')"><span class="toolTip"></span></a>should be<h3 class="titleHeading">My Title <a ng-click="openTooltip('getMoreInfo')"><span class="toolTip"></span></a></h3>and.text(...)is replacing everything inside the<h3>...</h3>.<h3 class="titleHeading">My Title</h3><a ng-click="openTooltip('getMoreInfo')"><span class="toolTip"></span></a>