一下脚本测试了jquery 以及jquery mobile的事件触发顺序
某次编程的时候,getBoundingClientRect获取element的大小,永远是0,原来是脚本的调用时机放错了位置;一般在ready处调用
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>[!--pagetitle--]</title>
<link href="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.css" rel="stylesheet" type="text/css"/>
<script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
<script>
$(document).on("mobileinit", function(){
alert(‘mobileinit‘);
});
</script>
<script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.js" type="text/javascript"></script>
</head>
<body class=‘page-swipe‘>
<script>
alert("script exect");
$(document).on(‘pagebeforechange‘, function(e, data){
alert(‘pagebeforechange‘);
});
$(document).on( "pagebeforecreate", function( event ) {
alert(‘pagebeforecreate‘);
});
$(document).on("pagecreate", function( event ) {
alert(‘pagecreate‘);
} );
$(document).on("pageinit","#page",function(){
alert(‘ page pageinit‘);
});
$(document).on(‘pageinit‘, function(){
alert(‘pageinit‘);
});
$(document).on(‘pagebeforeshow‘, function(){
alert(‘pagebeforeshow‘);
});
$(document).on( "pagecontainershow", function( event, ui ) {
alert( "pagecontainershow" );
});
$("#slider").ready(function(){
alert(‘ slider ready‘);
});
$(document).ready(function(){
alert(‘ready‘);
});
$(function(){
alert(‘jquery execte ready‘);
});
$(window).load(function() {
alert(‘window load‘);
});
window.onload=function(){
alert(‘onload‘);
};
$( window ).hashchange(function() {
alert(‘hashchange‘);
});
-->
</script>
</body>
</html>
原文:http://blog.csdn.net/lijinchao2007/article/details/19127911