首页 > 解决方案 > 无法检索文本框值

问题描述

我是 Jquery 的新手,如果这是错误的方式,请道歉

我有一个模板数组,我正在尝试根据表单中 CallerName 文本框中输入的文本添加 CallerName。

Var template_content=[
"Hello" CallerName,"\n \n" + "This is the dummy template 1".,
"Hello" CallerName,"\n \n" + "This is the dummy template 2".,
"Hello" CallerName,"\n \n" + "This is the dummy template 3".,
]

使用下面的 jquery 代码,我可以在警报框中获取 CallerName 文本框值,

var cname = $("[name='inc.caller_Name']");
var CallerName= cname.val();
//alert(CallerName)

下面是点击功能

$(".dropdown a").click(function(){
        var index=parseInt($(this).attr("index"));  
         var notes = $("[name='inc.comm']");
         notes.html(template_content[index]);
         
        $("#ac-textarea").html(template_content[index]); 
    });

所以我的问题是我在警报框中正确获取了 CallerName 值,但在模板中,CallerName 为空白。

标签: javascripthtmljquery

解决方案


嗨,沙龙,你可以尝试用val(template_content[index])html 代替吗


推荐阅读