javascript - 无法检索文本框值
问题描述
我是 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 为空白。
解决方案
嗨,沙龙,你可以尝试用val(template_content[index])
html 代替吗
推荐阅读
- javascript - 使用 AngularFire 调整 Firestore 缓存大小
- javascript - 为什么我的 jQuery 没有检测到对标签的点击?
- ruby-on-rails - CanCanCan“索引”规则有和没有块之间的区别
- c# - 本机 Xamarin.Android 应用程序在发布模式下不断崩溃
- javascript - 条件渲染输入重叠文本
- jquery - 通过 jQuery 下载时 Zip 文件无效
- boolean - 如何在 COBOL 中返回 true
- google-chrome - emoji/canvas/text 如何在 Chrome/Firefox 等浏览器上呈现?
- javascript - 如何隔离 React app.js 包中的组件
- flutter - 请帮助解决颤振应用程序得到这个问题