jQuery .attr('value') returns undefined for text area

痴心易碎 提交于 2019-12-01 11:10:56

Try .val() instead of .attr('value').

<textarea> doesn't have a value attribute (the text is between the tags, not in value="") however I believe .val() will retrieve it.

AJC

For textareas use :

 $("#textareaid").val() or $("#textareaid").html()

instead.

jQuery get textarea text

Set value of textarea in jQuery

TextArea does not have an attribute called value...try using val

map[cfe.attr('name')] = cfe.val();

textarea does not have a value attribute by default. You should use cfe.val() or cfe.html() to get its content.

It's because a textarea doesn't have a value attribute.

Use .val() instead.

Ok, so the reason is that jQuery 1.6 makes a distinction between the attribute at creation and your current property value. You've created the textarea without a value attribute more than likely; thus, the initial value is undefined. When you want to pull the defined value, you need to either use .prop('value'), or call the more helpful .val() method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!