Javascript 折旧率 折旧金额 净块 添加更多工作小提琴

Javascript 折旧率 折旧金额 净块 添加更多工作小提琴,javascript,jquery,html,radio-button,Javascript,Jquery,Html,Radio Button,您可以定义变量并增加该变量,然后在绑定之前将该变量附加到收音机上的name部分以获得唯一性,如下所示进行分组 var指数=0; $(文档).on('单击','.t1',函数(){ $(this.nextAll('.a:first').show(); $(this.nextAll('.b:first').hide(); }); $(文档).on('单击','.t2',函数(){ $(this.nextAll('.b:first').show(); $(this.nextAll('.a:first

您可以定义变量并增加该变量,然后在绑定之前将该变量附加到收音机上的name部分以获得唯一性,如下所示进行分组

var指数=0;
$(文档).on('单击','.t1',函数(){
$(this.nextAll('.a:first').show();
$(this.nextAll('.b:first').hide();
});
$(文档).on('单击','.t2',函数(){
$(this.nextAll('.b:first').show();
$(this.nextAll('.a:first').hide();
});
$(文档)。在('click','append radio',addmore radio');
函数addMoreRadio(){
索引++
$(“#追加_两者”)。追加(
“测试1”+
“测试2”+
'' +
'这是测试1扩展'+
'' +
'' +
'这是测试2扩展'+
''
);
}

测试1
测试2
这是测试1
这是测试2

添加更多工作小提琴

您可以定义变量并增加该变量,然后在绑定之前将该变量附加到收音机上的name部分以获得唯一性,如下所示进行分组

var指数=0;
$(文档).on('单击','.t1',函数(){
$(this.nextAll('.a:first').show();
$(this.nextAll('.b:first').hide();
});
$(文档).on('单击','.t2',函数(){
$(this.nextAll('.b:first').show();
$(this.nextAll('.a:first').hide();
});
$(文档)。在('click','append radio',addmore radio');
函数addMoreRadio(){
索引++
$(“#追加_两者”)。追加(
“测试1”+
“测试2”+
'' +
'这是测试1扩展'+
'' +
'' +
'这是测试2扩展'+
''
);
}

测试1
测试2
这是测试1
这是测试2

添加更多
我已经更新了您的代码,如果这对您有帮助,请查看

 $(document).on('click', '.t1', function () {
            if ($(this).parent().attr("id") == "append_both") {
                $(this).nextAll().eq(1).show();
                $(this).nextAll().eq(2).hide();
            }
            else {
                $('#t1_data').show();
                $('#t2_data').hide();
            }
        });

        $(document).on('click', '.t2', function () {
            if ($(this).parent().attr("id") == "append_both") {
                $(this).nextAll().eq(1).show();
                $(this).nextAll().eq(0).hide();
            }
            else {
                $('#t2_data').show();
                $('#t1_data').hide();
            }
        });

        $(document).on('click', '.append-radio', function () {

            var len = $('#append_both hr').length;
            addMoreRadio('test_data' + len);

        });

        function addMoreRadio(name) {
            $('#append_both').append(
              '<hr><input type="radio" name="' + name + '" class="t1"> Test 1' +
              '<input type="radio" name="' + name + '" class="t2">Test 2' +

              '<div class="t1_data" style="display:none;">' +
                'This is Test 1 Expanded' +
              '</div>' +

              '<div class="t2_data" style="display:none;">' +
                'This is Test 2 Expanded' +
              '</div>'
            );
        }
$(文档).on('单击','.t1',函数(){
if($(this.parent().attr(“id”)==“append\u二者”){
$(this.nextAll().eq(1.show());
$(this.nextAll().eq(2).hide();
}
否则{
$(“#t1_数据”).show();
$(“#t2_数据”).hide();
}
});
$(文档).on('单击','.t2',函数(){
if($(this.parent().attr(“id”)==“append\u二者”){
$(this.nextAll().eq(1.show());
$(this.nextAll().eq(0.hide());
}
否则{
$(“#t2_数据”).show();
$(“#t1_数据”).hide();
}
});
$(文档)。在('单击','上。附加无线电',函数(){
var len=$('#追加两个hr')。长度;
addMoreRadio(“测试数据”+len);
});
功能addMoreRadio(名称){
$(“#追加_两者”)。追加(
“
测试1”+ “测试2”+ '' + '这是测试1扩展'+ '' + '' + '这是测试2扩展'+ '' ); }
我已经更新了您的代码,如果这对您有帮助,请查看

 $(document).on('click', '.t1', function () {
            if ($(this).parent().attr("id") == "append_both") {
                $(this).nextAll().eq(1).show();
                $(this).nextAll().eq(2).hide();
            }
            else {
                $('#t1_data').show();
                $('#t2_data').hide();
            }
        });

        $(document).on('click', '.t2', function () {
            if ($(this).parent().attr("id") == "append_both") {
                $(this).nextAll().eq(1).show();
                $(this).nextAll().eq(0).hide();
            }
            else {
                $('#t2_data').show();
                $('#t1_data').hide();
            }
        });

        $(document).on('click', '.append-radio', function () {

            var len = $('#append_both hr').length;
            addMoreRadio('test_data' + len);

        });

        function addMoreRadio(name) {
            $('#append_both').append(
              '<hr><input type="radio" name="' + name + '" class="t1"> Test 1' +
              '<input type="radio" name="' + name + '" class="t2">Test 2' +

              '<div class="t1_data" style="display:none;">' +
                'This is Test 1 Expanded' +
              '</div>' +

              '<div class="t2_data" style="display:none;">' +
                'This is Test 2 Expanded' +
              '</div>'
            );
        }
$(文档).on('单击','.t1',函数(){
if($(this.parent().attr(“id”)==“append\u二者”){
$(this.nextAll().eq(1.show());
$(this.nextAll().eq(2).hide();
}
否则{
$(“#t1_数据”).show();
$(“#t2_数据”).hide();
}
});
$(文档).on('单击','.t2',函数(){
if($(this.parent().attr(“id”)==“append\u二者”){
$(this.nextAll().eq(1.show());
$(this.nextAll().eq(0.hide());
}
否则{
$(“#t2_数据”).show();
$(“#t1_数据”).hide();
}
});
$(文档)。在('单击','上。附加无线电',函数(){
var len=$('#追加两个hr')。长度;
addMoreRadio(“测试数据”+len);
});
功能addMoreRadio(名称){
$(“#追加_两者”)。追加(
“
测试1”+ “测试2”+ '' + '这是测试1扩展'+ '' + '' + '这是测试2扩展'+ '' ); }
尝试将classname与sibling selectorI一起使用我将检查…..尝试将classname与sibling selectorI一起使用我将检查…..在增量后,我还将控制父值,我希望在扩展的收音机下面有一个新值“Test 1 Expanded”。。。我应该增加“DIV ID”吗?是的,它工作得很好,但我不知道会发生什么,在我的项目中它无法工作。。。(与这个问题稍有不同)$(this.nextAll('.a:first').show();在我的项目中不工作,但在控制台或网络中没有错误。。有什么想法吗?如果看不到其他代码,就不可能说出它为什么不适用于您的项目。这与jquery版本无关。如果我将代码片段更新到实际项目中,您能看看我的代码吗?增量后,还可以控制父值,我希望在扩展的无线电下面有一个新值“Test 1 Expanded”。。。我应该增加“DIV ID”吗?是的,它工作得很好,但我不知道会发生什么,在我的项目中它无法工作。。。(与这个问题稍有不同)$(this.nextAll('.a:first').show();在我的项目中不工作,但在控制台或网络中没有错误。。有什么想法吗?如果看不到其他代码,就不可能说出它为什么不适用于您的项目。这与jquery版本无关。如果我将代码片段更新到真实项目中,您能看看我的代码吗?是的,它可以用,但有一件事是,每当我们展开单选并选择其中一个按钮时,上一个选中的收音机已关闭,我可以看到单选按钮为s