0

我一直在为使用三态 jquery 插件的客户端工作,经过大量调试后,我发现隐藏的输入没有显示:

<ul>
    <li>
        <a href="#" class="checkbox checked">undefined</a>
        <input type="checkbox" style="display: none; " />
        <label for="england" class="checkbox">England</label>
        <span class="toggler opened">&nbsp;</span>
        <ul style="display: block; ">
            <li class="city">
                <a href="#" class="checkbox checked">undefined</a>
                <input type="checkbox" value="leeds" id="cb_leeds" style="display: none; " />
                <label for="cb_leeds" class="checkbox" >Leeds</label>
            </li>
            <li class="city">
                <a href="#" class="checkbox checked">undefined</a>
                <input type="checkbox" value="london" id="cb_london" style="display: none; " />
                <label for="cb_london" class="checkbox checked" >London</label>
            </li>
        </ul>
    </li>
</ul>

我发现在他们使用的插件中,他们的脚本中有这个:

$('#pf-locations .city input:checked').each(function() {
    cities.push($(this).val());
});

有谁知道我怎样才能让插件检查隐藏的输入?谢谢!

4

1 回答 1

1

你可以试试这个:

$('#pf-locations .city label.checked').each(function() { // keeping ref of label
    cities.push($(this).prev(':checkbox').val()); // using label ref get input value
});
于 2012-06-11T14:53:54.820 回答