include jsp inside a jsp, how to remove include jsp when click a button in jsp?

I want to create a button to remove include jsp when on browser.

How to remove include jsp by clicking a button?

<jsp:include page="/test.jsp" />

1 answer

  • answered 2018-07-11 04:06 lucumt

    <jsp:include page="/test.jsp" /> happens on server side and you can only remove it in client side.You can use jQuery or Javascript to remove it.

    Suppose the content of test.jsp is as below:

    <div id="test">
     //other content

    The you can remove like below:

    <button type="button" onclick="removeInclude(this)">Remove</button>
    function removeInclude(obj){

    Note:if the content of test.jsp do not have more than one element as below,then you need to remove them one by one:

    <div id="test1">
     //other content
    <div id="test2">
     //other content
    <div id="test3">
     //other content

    in this case,you can use jQuery like $("#test1,#test2,#test3").remove()