繁体   English   中英

如何在jQuery中合并两个$(document).ready(function()

[英]How to merge two $(document).ready(function() in jQuery

<script src="jQuery/jquery.tablesorter.min.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>



$(document).ready(function() {

    $("#myTable").tablesorter({

    });

    $("#accordion").accordion({ 
        autoHeight: false, collapsible: true, active: false
    });



});

...

<div id="accordion">
    <h3><a href="#">First header</a></h3>
    <div>First content</div>
    <h3><a href="#">Second header</a></h3>
    <div>Second content</div>
</div>

<table border =1 cellpadding =8 id="myTable" class="tablesorter" WIDTH="80%">
<thead>
<th><h3> Date </h3></th>
<th><h3> Report </h3></th>
</thead><tbody>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</tbody></table>

jQuery后需要加载tablesorter

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
 <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
 <script src="jQuery/jquery.tablesorter.min.js"></script> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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