Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何获取当前窗格主体下的复选框数据id_Jquery - Fatal编程技术网

Jquery 如何获取当前窗格主体下的复选框数据id

Jquery 如何获取当前窗格主体下的复选框数据id,jquery,Jquery,现在,问题是: 当复选框获取点击事件时,如何获取当前obj中所有复选框数据id值 我希望可以获取当前panner主体下的所有数据id值,然后将它们连接到一个字符串,每个字符串之间有一个字符“,”尝试使用jquery的map和get来实现您想要的 $(document).on('click', '[data-share="default"]', function () { if ($(this).prop("checked")) { $(th

现在,问题是: 当复选框获取点击事件时,如何获取当前obj中所有复选框数据id值


我希望可以获取当前panner主体下的所有数据id值,然后将它们连接到一个字符串,每个字符串之间有一个字符“,”

尝试使用jquery的
map
get
来实现您想要的

$(document).on('click', '[data-share="default"]', function () {
            if ($(this).prop("checked")) {
                $(this).attr("checked");
                //get current panner-body children's input data-id
                var obj = $(this).parents(".panel-body");
                alert("");
            }
            else {
                $(this).removeAttr("checked");
            }
        })
$(document).on('单击',')。面板主体。复选框输入[类型=复选框]:选中',函数(){
var tempIdArr=[];
//选中“当前代码”复选框
tempIdArr[0]=$(this.attr('data-id');
//结束代码
//现在为面板主体中的所有选中复选框编码
var tempLen=$('.panel body.checkbox输入[type=checkbox]')。长度;
对于(var i=0;i
您想要所有复选框ID还是所有复选框数据ID?
$(document).on('click', '[data-share="default"]', function () {
            if ($(this).prop("checked")) {
                $(this).attr("checked");
                //get current panner-body children's input data-id
                var obj = $(this).parents(".panel-body");
                alert("");
            }
            else {
                $(this).removeAttr("checked");
            }
        })
$(document).on('click', '[data-share="default"]', function() {
  if ($(this).prop("checked")) {
    var obj = $(':checkbox[data-share="default"]', $(this).closest(".panel-body"));
    alert(obj.map(function() {
      return $(this).data("id");
    }).get());
  }
});
$(document).on('click', '.panel-body .checkbox input[type=checkbox]:checked', function() {
                var tempIdArr = [];
            //code for current checked check box
            tempIdArr[0] = $(this).attr('data-id');
            //end code
            //now code for all checked check-box in panel-body
            var tempLen = $('.panel-body .checkbox input[type=checkbox]').length;

            for (var i = 0; i < tempLen; i++) {
                if ($('.panel-body .checkbox').eq(i).find('input[type=checkbox]').attr('checked')) {
                    tempIdArr[i] = $('.panel-body .checkbox').eq(i).find('input[type=checkbox]').attr('data-id');
                }
            }
            for (var i = 0; i < tempIdArr.length; i++) {
                console.log("'data-id' :" + "\n" + tempIdArr[i]);
            }

        });