我正在使用数十个 jQuery 插件和我的自己编写的 jQuery 脚本,在每一个脚本中我都有如下代码:
$(document).ready(function()
{ .... }
如何将所有脚本组织到一个集中的位置,并且不需要在脚本中多次使用$(document).ready(function()。
有何想法?
更新
one.js
$(document).ready(function() {
$("#aspnetForm").validate({
rules:
{
<%=txtVisitName.UniqueID %>:
{
maxlength:1,
required: true
},
deleted lines......
two.js
$(document).ready(function() {
$("#btnSubmit").click(function(event) {
if ($("#aspnetForm").valid())
SaveVisitBasicPage();
deleted lines......
three.js
$(document).ready(function() {
function initMenu() {
$('#menu ul').hide();
$('#menu li a').click(
deleted lines......
four.js
$(document).ready(function() {
$("#ctl00_cphMaster_txtPurpose").NobleCount('#count01',
{
max_chars: 25,
on_negative: 'go_red',
on_positive: 'go_green',
block_negative: true
deleted lines......
我应该如何组织以上的.js文件呢?你可以看到上面有多个$(document).ready(function()。