绑定功能提交在文件准备

bind function on submit in document ready

本文关键字:文件 功能 提交 绑定      更新时间:2023-09-26

我正在学习javascript。我如何绑定这个函数提交文件准备好了吗?

jQuery(function($) {
    $('form').bind('submit', function() {
       $(this).find(':select').removeAttr('disabled');
    });
});

谢谢

$(document).ready(function() {
    /* your code here */
    $('form').bind('submit', function() {
       $(this).find(':select').removeAttr('disabled');
    });
    /* end your code */
});

就是这么简单——一旦文档"就绪",绑定就会就位——要了解更多信息,请访问jQuery教程网站,了解有关$(document).ready()事件的信息:http://learn.jquery.com/using-jquery-core/document-ready/

对于文档"ready"事件,有两个jQuery选项:

$(document).ready():当你的dom完全加载后,jQuery将触发ready事件。

$(document).load(): jQuery等待,直到你的dom和所有你声明的资产被加载。所以,如果你的javascript代码依赖css属性,使用这个

更多信息请查看:http://api.jquery.com/ready/