为了向文本区域添加值,我从jquery函数中缺少什么
What am i missing from jquery function in order to add value into a textarea
用户单击"添加"按钮后,我正在尝试将一些内容添加到文本区域中,但没有任何反应。我缺少什么吗?
下面是添加所选内容的 jquery 代码:
$(".add").on("click", function(event) {
console.log("clicked");
//lets get our Question Text...
var theQuestion = $("td:first-child", $(this).parent()).text();
//the row is present, let's then make sure that the proper cell gets oru data.
if ($('.activePlusRow').length > 0) {
$('.activePlusRow').next('.textAreaQuestion').val(theQuestion);
$('.activePlusRow').removeClass('activePlusRow');
}
});
$(".plusrow").on("click", function(event) {
//adding a unique class for the purpose of the click.
$(this).addClass('activePlusRow');
});
下面是文本区域:
$('.questionTextArea').each( function() {
var $this = $(this);
var $questionText = $("<textarea class='textAreaQuestion'></textarea>").attr('name',$this.attr('name')+"[]")
.attr('value',$this.val());
});
编辑:
您可以使用该应用程序亲自查看。以下是如何使用应用程序:
- 当您打开应用程序时,单击"绿色加号"按钮。将出现一个模式窗口。
- 在搜索框中输入"AAA",然后单击"搜索"。
- 将显示搜索结果。这就是问题所在。我想要的是,当用户单击"添加"按钮添加"问题"时,它应该关闭模态窗口并将"问题"添加到顶部文本区域中,但它没有这样做。
与输入不同,文本区域不使用 value 属性来存储数据,这可能就是 attr('value', 'bla') 失败的原因。
我相信 .val() 方法会自动考虑到这一点,因此无论如何都可以工作。
尝试类似操作:
var $questionText = $("<textarea class='textAreaQuestion'></textarea>").attr('name',$this.attr('name')+"[]").val($this.val());
相关文章:
- 执行ajax成功函数-jQUERY
- 函数jquery.html()不提供数据属性集值
- 将变量放入ajax函数JQuery
- 函数jquery的未定义返回
- 如何在嵌套函数jquery上保持变量的值不变
- 用我的函数jquery给出数据/参数
- Firefox在调用函数(jquery)时冻结
- 在传递节时触发一个函数 - jquery
- 循环执行数组函数jQuery
- 在函数中调用另一个函数JQuery
- 对象不是函数-Jquery/JavaScript
- TypeError:对象不是函数-jquery
- 获取函数jQuery设置的属性
- 从函数jquery获取更新的变量值
- 切换而不是悬停函数jQuery
- 函数jQuery.animation()运行了两次行,但不起作用
- 使用函数 jQuery 获取变量
- 自执行函数 jquery 与 JavaScript 的区别
- 从回调函数 -JQuery 获取返回值
- 一个接一个地执行函数 JQUERY