[removed] get contents of textarea, textContent vs. innerHTML vs. innerText

前端 未结 2 1991
小鲜肉
小鲜肉 2021-01-02 04:11

I am having trouble getting the contents of a textarea with js. I feel like I\'ve done this many times before without problems but something is throwing it off or I have a

相关标签:
2条回答
  • 2021-01-02 04:33

    This are your code?

    you write document.getElementByID.... and the "D" should be written lowercase "d"

    document.getElementById('productdescript').textContent;
    
    0 讨论(0)
  • 2021-01-02 04:40

    For textarea, you could only use .value in your scenario (I tested your given code and it works fine). .

    Also,

    1) keep in mind that you call this function addProduct() ONLY after your element is mentioned in the code, otherwise it will be undefined.

    2) there must not be another element with id as productdescript

    3) there must not be a JS variable called productdescript

    0 讨论(0)
提交回复
热议问题