【问题标题】:Load a jsp on div element on checkbox在复选框上的 div 元素上加载 jsp
【发布时间】:2013-02-24 08:18:48
【问题描述】:

如果有任何复选框=选中如果未选中隐藏 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>

【问题讨论】:

    标签: jquery ajax jsp checkbox


    【解决方案1】:

    请也阅读内联 cmets。

    $(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('');
            }
        });
    }
    

    【讨论】:

    • 谢谢!直接打jsp
    猜你喜欢
    • 2020-02-24
    • 1970-01-01
    • 1970-01-01
    • 2021-02-07
    • 1970-01-01
    • 2014-12-07
    • 1970-01-01
    • 2019-02-13
    • 1970-01-01
    相关资源
    最近更新 更多