gpt4 book ai didi

javascript - 从 textarea 对象获取 textarea 值

转载 作者:行者123 更新时间:2023-11-30 17:54:47 27 4
gpt4 key购买 nike

为什么这行不通?这里的input类型是text:

var name = $("input[name='Event[name]']").serializeArray();
name = name[0].value;

var description = $("input[name='Event[description]']").serializeArray();
description = description[0].value;

当我想从 textarea 获取时,它不起作用。

最佳答案

这应该有效:

var name = $("input[name='Event[name]']").val();

var description = $("input[name='Event[description]']").val();

让 jQuery 处理 value .

The .val() method is primarily used to get the values of form elements such as input, select and textarea.

关于javascript - 从 textarea 对象获取 textarea 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18272864/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com