J
J
JRazor2015-10-02 17:31:55
JavaScript
JRazor, 2015-10-02 17:31:55

JavaScript: how to add text to a tag with a tag inside?

Hello fellow toasters.
The customer's designer designed the code in the following way:

<li><i class="fa fa-map-marker"></i> Pierrelatte</li>

Only the text needs to be changed (in the example it is "Pierrelatte"). The i tag in this case displays a marker. As a backend, I need to send the text inside the li tag using JS , but everything is complicated by the tag contained inside. How to solve this issue?
The following options come to mind:
1) Ditch the code even more by stuffing another tag inside.
2) Pass the inner tag directly to JS (squalor, and nothing more).
3) Show the designer for his methods of solving the problem.
Thanks everyone for the replies.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Inchin ☢, 2015-10-02
@JRazor

You can get the Text Node inside li and modify its content. Like this.

A
Alexander, 2015-10-02
@kentuck1213

jsfiddle.net/99ehzh5o/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question