How to change the text 'save' to 'edit' in this html code using jquery
<a id="personalSave" href="#" class="SaveText">
<span class="FloatLeft">‹</span>
save
<span class="FloatRight">›</span>
</a>
i tried changing the text(save between the spans ) using
$('#personalSave').innerText = "edit";
but its not working..
How to change the text 'save' to 'edit' in this html code using jquery
<a id="personalSave" href="#" class="SaveText">
<span class="FloatLeft">‹</span>
save
<span class="FloatRight">›</span>
</a>
i tried changing the text(save between the spans ) using
$('#personalSave').innerText = "edit";
but its not working..
Share Improve this question edited Aug 2, 2013 at 10:28 iJade asked Aug 2, 2013 at 10:22 iJadeiJade 23.8k58 gold badges160 silver badges250 bronze badges 4- 1 Change it when what? Click on link or what? Improve your question please... – A. Wolff Commented Aug 2, 2013 at 10:24
- 1 Mhm... What? Can you please explain better? – Niccolò Campolungo Commented Aug 2, 2013 at 10:24
-
Use
$('#personalSave').text('edit')
instead... – Niccolò Campolungo Commented Aug 2, 2013 at 10:29 - @LightStyle dat did the trick – iJade Commented Aug 2, 2013 at 10:32
3 Answers
Reset to default 4This is what worked for me
$('#personalSave').text('edit');
Wrap your text also in a span:
<a id="personalSave" href="#" class="SaveText">
<span class="FloatLeft">‹</span>
<span class='txt'>save</span>
<span class="FloatRight">›</span>
</a>
Now you can select it:
$('#personalSave .txt').text("edit");
This should work but it's probably not the best way to do it:
$("#personalSave").text($("#personalSave").text().replace("save", "edit"));
Better wrap the text in a span and change that.