Javascript 从Jquery中的字符串中删除子字符串
我正在为复选框列表的click事件编写一个jQuery函数,当选中一个项目时,它将值存储在字符串中,当它未选中时,它将删除该字符串。我正在获取闭合标签文本,并将其插入字符串并从字符串中删除。我可以添加字符串,但无法删除它 这是我的密码:Javascript 从Jquery中的字符串中删除子字符串,javascript,jquery,asp.net,Javascript,Jquery,Asp.net,我正在为复选框列表的click事件编写一个jQuery函数,当选中一个项目时,它将值存储在字符串中,当它未选中时,它将删除该字符串。我正在获取闭合标签文本,并将其插入字符串并从字符串中删除。我可以添加字符串,但无法删除它 这是我的密码: var currentage = ''; $('#<%=chk_ange.ClientID%> input:checkbox').click(function () { var str = $(this).next('label').tex
var currentage = '';
$('#<%=chk_ange.ClientID%> input:checkbox').click(function () {
var str = $(this).next('label').text();
if ($(this).is(':checked')) {
if (currentage.indexOf($(this).next('label').text()) == -1) {
currentage = currentage + str;
}
alert('checked' + currentage);
}
else {
currentage.replace(str, "Hello");
//currentage.replace(str, 'None');
alert('unchecked' + currentage);
}
}
var currentage='';
$(“#输入:复选框”)。单击(函数(){
var str=$(this.next('label').text();
如果($(this).is(':checked')){
if(currentage.indexOf($(this).next('label').text())==-1){
currentage=currentage+str;
}
警报(“已检查”+当前日期);
}
否则{
currentage.replace(str,“Hello”);
//currentage.replace(str,'None');
警报(“未选中”+当前日期);
}
}
我将这些值存储在一个全局变量中,以便在每次单击时比较值。您必须将
replace
的结果分配回您的变量,如:
currentage = currentage.replace(str, "Hello");
请参阅:您必须将
replace
的结果分配回变量,如下所示:
currentage = currentage.replace(str, "Hello");
请参阅:您必须将
replace
的结果分配回变量,如下所示:
currentage = currentage.replace(str, "Hello");
请参阅:您必须将
replace
的结果分配回变量,如下所示:
currentage = currentage.replace(str, "Hello");
请参阅:您需要将
currentage.replace(str,“Hello”);
与currentage
的结果相等。字符串是不可变的,因此replace()
函数返回一个新修改的字符串
currentage = currentage.replace(str, "Hello");
您需要将
currentage.replace(str,“Hello”);
到currentage
的结果相等。字符串是不可变的,因此replace()
函数返回一个新修改的字符串
currentage = currentage.replace(str, "Hello");
您需要将
currentage.replace(str,“Hello”);
到currentage
的结果相等。字符串是不可变的,因此replace()
函数返回一个新修改的字符串
currentage = currentage.replace(str, "Hello");
您需要将
currentage.replace(str,“Hello”);
到currentage
的结果相等。字符串是不可变的,因此replace()
函数返回一个新修改的字符串
currentage = currentage.replace(str, "Hello");
哦,那是个错误,感谢快速反应解决了…有时它只是从视力上消失…@user2664298,是的,发生了:),你很好哦,那是个错误,感谢快速反应解决了…有时它只是从视力上消失…@user2664298,是的,发生了:),你很好哦那是个错误谢谢你的快速反应解决了…有时它只是从视力中消失…@user2664298,是的,发生了:),你很好哦那是个错误谢谢你的快速反应解决了…有时它只是从视力中消失…@user2664298,是的,发生了:),欢迎你