爲什麼jquery獲取textarea修改後的值沒變?

最近在開發字幕醬(https://www.zimujiang.com/),一個自動生成字幕的在線工具,在開發字幕在線編輯功能的時候遇到一個問題。

就是前端textarea值修改之後,js獲取的值仍然是原來的舊值!

這是爲什麼呢?

先看html規範的定義:

The name attribute specifies a name for a text area.

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.

然後是格式:

<textarea name="text">

各位看明白沒有,雖然我們獲取textarea的值可能是通過id,但是這個name值必須要有。

試試給textarea加個name屬性看看,是不是就好了~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章