Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.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访问高度嵌套的输入_Jquery_Html_Alert_Nested_Contact Form 7 - Fatal编程技术网

Jquery访问高度嵌套的输入

Jquery访问高度嵌套的输入,jquery,html,alert,nested,contact-form-7,Jquery,Html,Alert,Nested,Contact Form 7,我试图访问一个嵌套在一组和一个中的输入。我无法更改它的嵌套方式,因此我唯一能做的就是尝试找到访问它的方法。下面是我的代码嵌套的方式。(无法更改)。inb4我的JQuery被启用了,我事先已经做了一些测试警报 <div id="chargeRequest "> <p>Chargeable Request - If selected fill section below<br> <span class="wpcf7-form-cont

我试图访问一个嵌套在一组
和一个

中的输入。我无法更改它的嵌套方式,因此我唯一能做的就是尝试找到访问它的方法。下面是我的代码嵌套的方式。(无法更改)。inb4我的JQuery被启用了,我事先已经做了一些测试警报

<div id="chargeRequest ">
    <p>Chargeable Request - If selected fill section below<br>
        <span class="wpcf7-form-control-wrap checkbox-397">
            <span class="wpcf7-form-control wpcf7-checkbox">
                <span class="wpcf7-list-item first last">
                    <input type="checkbox" name="checkbox-397[]" value="yes">
                    <span class="wpcf7-list-item-label">yes
                    </span>
                </span>
            </span>
        </span>
    </p>
</div>
第二次尝试是在To try中使用span类一层,然后查找输入。一旦它找到了一个,它就会检查它是否被检查过。这里也没有发生什么事

if ($('.checkbox-397').find('input')) {
    if (this.is('checked')) {
        alert('test');
    }
}
第三次尝试,我绝望了,试图做一个大的嵌套链。这不起作用,请参见下面的2次嵌套尝试

if ($('#chargeRequest>p>span>span>input:checked')) {
        alert('test');
    }
}

if ($('#chargeRequest>p>span>span>input').is(':checked')) {
        alert('test');
    }
}

上面的方法我也尝试了
.prop()
,但都没有

,我认为问题在于标记中选择器id中的
空间:

<div id="chargeRequest ">

收费请求-如果选择,请填写下面的部分


您的第一次尝试应该是有效的,只有一件事,从id中删除空格

应该是

您还可以选择如下输入:

 if ($('#chargeRequest input').prop('checked')) {
    alert('test');
}

$('input')。单击(函数(){
if($('#chargeRequest input').prop('checked')){
警报(“测试”);
}
})

收费申请-如果选择,请填写下面的部分


if语句在哪里运行这些
if语句?它只有在我删除空格时才开始运行。多谢各位。这样一个愚蠢的错误,占了我们的上风;)
<div id="chargeRequest">
 if ($('#chargeRequest input').prop('checked')) {
    alert('test');
}