G
G
Good Samaritan2018-02-14 11:52:12
JavaScript
Good Samaritan, 2018-02-14 11:52:12

How to add a tag to a page?

I have a list of elements on the page

<h2 class="node-title"><a href="1">1</a></h2>
<h2 class="node-title"><a href="2">2</a></h2>
<h2 class="node-title"><a href="3">3</a></h2>
....

I need to add one more tag to each a tag. <a href="edit">edit</a>
I'm trying like this:
var edit = document.createElement('a');
    edit.innerHTML = 'edit';
    node-title.appendChild(edit);

Does not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-02-14
@djamali

Let me turn on telepathy, and even guess what error it shows. Telepathy is indispensable here.
Something like "node is not defined", am I right? Because you have node-title...something there (node ​​variable MINUS title variable...), but you did not declare the node variable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question