0

如果任何复选框=选中如果未选中隐藏 div 元素,我需要在 div 元素上加载 jsp 页面。到目前为止,我已经尝试过这个,但它根本不起作用!帮助!

JS:

    $(document).ready(function(){
$.each($("input[type=checkbox]:checked"),function(){
    $("verification").load("/selectionPage");
});

JSP:

<td class="cb" bgcolor='<c:out value="${summary.color}"></c:out>'><input
                        type="checkbox" value="">
                    </td>
                </tr>
            </c:forEach>
    </tbody>
</table>
       </div>
     <div id="verification"></div>
4

1 回答 1

1

也请阅读内联评论。

$(document).ready(function () {
    $("input[type=checkbox]").click(function () {

        //things you want to do when the checkbox is checked
        //like loading the jsp
        if ($(this).attr('checked') === 'checked') {

            //make sure the selector is correct. # for id, . for class etc.
            //also, /selectionPage or /selectionPage.jsp?
            //Basically, path resolver or hitting JSPs directly?
            $('#verification').load('/selectionPage.jsp', function () {
                console.log('done');
            });
        }

        //things you want to do when the checkbox is unchecked
        //like maybe clearing the div?
        else {
            $('#verification').html('');
        }
    });
}
于 2013-03-08T17:41:55.477 回答