问题描述
如何在javascript中将变量值用作id
iam将文本框值赋予使用json。使用textbox id但id是变量值。使用循环动态变量值变化。
我尝试过:
< asp:TextBox ID =title0runat =server>
< asp:TextBox ID =title1runat =server>
$ .each(jsonData.d,function(){
var title =title+ iCnt;
// var tittleid = title + iCnt;
$([id $ ='title'])。val(jsonData .d [iCnt] .labeltext);
});
how to use variable value as id in javascript
iam assign textbox value to using json. using textbox id but id is an variable value . that variable value change in dynamic with use of loop.
What I have tried:
<asp:TextBox ID="title0" runat="server" >
<asp:TextBox ID="title1" runat="server" >
$.each(jsonData.d, function() {
var title = "title" + iCnt;
//var tittleid = title + iCnt;
$("[id$='title']").val(jsonData.d[iCnt].labeltext);
});
这篇关于如何在javascript中将变量值用作id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!