引入jquery分页插件

html代码
<!DOCTYPE html>
<html>
<head>
<script src="jquery.pagination.js"></script>
<script src="jquery-1.11.1.min.js"></script>
<script >
alert(1);
$('.M-box').pagination({

callback:function(index){
    $('.now').text(index);
}

},function(api){

$('.now').text(api.getCurrent());

});
</script>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div class="M-box"></div>
</body>
</html>

jquery.pagination.js和jquery-1.11.1.min.js文件都放项目下了
报错Uncaught ReferenceError: jQuery is not defined
43.html:8
Uncaught TypeError: $(...).pagination is not a function word_search.js:155
Uncaught TypeError: Cannot read property 'id' of null

发现jquery,js应该在第一行。。改了之后

Uncaught TypeError: Cannot read property 'id' of null 这个错啥意思。。

阅读 4.2k
1 个回答

请使用$(document).ready,保证代码在DOM加载完成后执行

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进