Insert values Inside table using javascript

Asked

Viewed 41 times

-1

I need to create a input within a cell of a table using Javascript. I created a tag <a> with name="ex2"

<tr><p>
<td id="secTd"><label for="cAp"><a id="num">02</a> <a id="texto">Time</a></label></td>
<td id="tecTd"><a name="ex2"></a></td>
</p></tr>

And I’m using this Javascript code to write "val1" inside this tag.

document.getElementById("exibe1").innerHTML = "val1";

No error message appears, same thing if I try with a input.

  • I tried to translate, but the question seems to me to make no sense.

1 answer

1

If I understand correctly, the problem is just searching with Javascript an element whose id is exibe1 as long as the desired element is id defined has. You can then properly define the property in the widget or do:

document.querySelector("a[name='ex2']").innerHTML = "val1";
<tr>
  <p>
    <td id="secTd"><label for="cAp"><a id="num">02</a> <a id="texto">Time</a></label></td>
    <td id="tecTd">
      <a name="ex2"></a>
    </td>
  </p>
</tr>

This element p defined within the tr doesn’t seem to make sense.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.