JavaScript JavaScript and the DOM Making Changes to the DOM Modifying Elements

Sumalee Juntra
Sumalee Juntra
8,420 Points

I can't solve this task. :(

Next, set the text content of the <a> element with the ID link to the value stored in inputValue.

var inputValue = document.getElementById('linkName').value;
<!DOCTYPE html>
        <title>DOM Manipulation</title>
    <link rel="stylesheet" href="style.css" />
        <div id="content">
            <label>Link Name:</label>
            <input type="text" id="linkName">
            <a id="link" href=""></a>
        <script src="app.js"></script>

2 Answers

Xavier Ritch
Xavier Ritch
9,009 Points

Hope you got this one figured by now but if not, the challenge task is asking you to set the textContent of the <a> tag equal to the value of the inputValue variable. So first we would select the <a> tag with getElementById and then call textContent on it, then store that in our variable So it should look something like this:

var inputValue = document.getElementById('linkName').value; document.getElementById('link').textContent = inputValue;

hope this helps!

Sumalee Juntra
Sumalee Juntra
8,420 Points

Yay! I solved it! Thanks so much Xavier Ritch. ;)

try removing the quotations, play around with the syntax, that usually works, I remember being stuck on this one as well

Sumalee Juntra
Sumalee Juntra
8,420 Points

Thank you so much for your help. :)