本文摘自PHP中文网,作者(*-*)浩,侵删。
入口函数的作用,等待页面加载完毕,有一个独立的作用域,
jQuery入口函数的编写方式如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <script>
$(document).ready( function () {
alert( "hello lnj" );
});
$( function () {
alert( "hello lnj" );
});
jQuery(document).ready( function () {
alert( "hello lnj" );
});
jQuery( function () {
alert( "hello lnj" );
});
</script>
|
实例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <html>
<head>
<meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" />
<script src= "jquery-1.7.1.js" type= "text/javascript" ></script>
</head>
<body style= " overflow-y:scroll;overflow-x:auto;" >
<input type= "text" id= "dd1" value= "" />
<textarea id= "tt" cols= "30" rows= "30" ></textarea>
</body>
<script>
var i=1;
$( function (){
var str=$( "#tt" ).val()+ '\r\n' + '$_B加载完毕' +i;
$( "#tt" ).val(str);
i++;
}) ;
</html>
|
以上就是jquery为什么写入口函数的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
jQuery版本号如何隐藏
jQuery中如何获取图片真实大小
jQuery获取元素到顶部距离的方法
使用jQuery能做什么
jQuery怎么判断对象是否存在
jQuery中的美元符号$有什么作用
jQuery hasclass()怎么用
jQuery中$("#")与$("#"+xx)的差异
jQuery怎么获取星期几
jQuery有哪些框架
更多相关阅读请进入《jQuery》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » jquery为什么写入口函数