简体   繁体   中英

does $(document).ready(function()) execute only after jsp is loaded

I am trying to use the datatable jquery plugin to a table that is populated by a JSP . I add the datatable initialisation in the $(document).ready(function()) but for some reason the plugin is not able to perform the search or pagination . my code snippet is

<table class="data-table" id="test">
    <thead>
        <tr>
            <th>value1</th>
            <th>value2</th>
            <th>value3</th>
            <th>value4</th>

        </tr>
    </thead>
    <tbody>


        <tr>
            <td class="class1"><%= value.valueOne() %></td>
            <td class="class2"><%= value.valueTwo() %></td>
            <td class="class3"><%= value.valueThree() %></td>


            <td class="class4"><%= value.valueFour() %></td>
        </tr>
        <%
        }
        %>
    </tbody>
</table>


<script>
   $(document).ready(function()  {
        alert("HELLO");
        $('#test').dataTable();

       });
</script>

Anybody else who has faced this issue , any help would be appreciated .

$(document).ready() function is executed when your full page is loaded, no matter where you write it in code. More info: http://learn.jquery.com/using-jquery-core/document-ready/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM