Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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
Javascript jquery检查当前元素上下文 $('.questions input').iCheck({ checkboxClass:'icheckbox_line-blue', 无线电课程:“伊拉迪奥蓝线”, 插入:“” });_Javascript_Jquery_Html_Icheck - Fatal编程技术网

Javascript jquery检查当前元素上下文 $('.questions input').iCheck({ checkboxClass:'icheckbox_line-blue', 无线电课程:“伊拉迪奥蓝线”, 插入:“” });

Javascript jquery检查当前元素上下文 $('.questions input').iCheck({ checkboxClass:'icheckbox_line-blue', 无线电课程:“伊拉迪奥蓝线”, 插入:“” });,javascript,jquery,html,icheck,Javascript,Jquery,Html,Icheck,使用这种方法不适合我的需要: $('.questions input').iCheck({ checkboxClass: 'icheckbox_line-blue', radioClass: 'iradio_line-blue', insert: '<div class="icheck_line-icon"></div>' }); $('.questions input')。每个(函数(){ var self=$(此), label=sel

使用这种方法不适合我的需要:

$('.questions input').iCheck({
     checkboxClass: 'icheckbox_line-blue',
     radioClass: 'iradio_line-blue',
     insert: '<div class="icheck_line-icon"></div>'
});
$('.questions input')。每个(函数(){
var self=$(此),
label=self.next(),
label_text=label.text();
label.remove();
自我检查({
checkboxClass:'icheckbox_line-blue',
是的,
无线电课程:“伊拉迪奥蓝线”,
插入:“”+标签\文本
});
});
如何检索当前上下文?我想显示标签标签之间的文本。 我的html看起来像

$('.questions input').each(function () {

    var self = $(this),
    label = self.next(),
    label_text = label.text();

    label.remove();
    self.iCheck({
         checkboxClass: 'icheckbox_line-blue',
         transferClasses: true,
         radioClass: 'iradio_line-blue',
         insert: '<div class="icheck_line-icon"></div>' + label_text
    });

});

问答文本
试试这个

<div class="questions">
    <div class="question">
         <input type="checkbox" name="iCheck">
         <label>Question answer text</label>
    </div>
</div>

演示

谢谢,似乎效果不错,但我需要回答每个问题。。。现在我正在获取文本,并将其保存到所有复选框中。等等,我也将在itOk中帮助您,但似乎我又回到了我在问题中显示的示例(第二段代码)。如果我使用它,那么iCheck插件不会正确包装“label”元素它会产生什么问题?@dreamweiver:您只需更改事件调用其他元素的方式,就像我的代码一样。
 $('.question input[type=checkbox]').each(function(){
    alert($(this).next('label').html());

});