Getting the values of textboxes in Javascript

前端 未结 6 1877
梦谈多话
梦谈多话 2021-01-25 03:41

I have this html code:

Song:
6条回答
  •  不知归路
    2021-01-25 04:21

    First, td elements don't have a value attribute, so calling .value on them won't do a thing. Second, the value is actually on the input element, so you need to do mytable.getElementsByTagName('input') instead. Even better would be to give your input fields ids and then use getElementById. This would mean you could alter your HTML without your JS breaking.

提交回复
热议问题