选定的 jquery 插件在 wamp 中不起作用
首先,我在 php 文件上运行此代码,并使用 WampServer 在本地主机上运行它。分页不起作用,所以我尝试将其转换为 html 文件(“sample.html”)。这里的代码如下。
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="js/easypaginate.js"></script>
<script type="text/javascript">
jQuery(function($){
$('ul#items').easyPaginate({
step:5
});
});
</script>
<style>
#page li {
display: inline;
position: relative;
width: 11em
margin:10px;
padding:10px;
}
#page li li{ display: block; height: 1.5em;}
</style>
<div id = "page">
<ul id="items">
<li>Page 1</li>
<li>Page 2</li>
<li>Page 3</li>
<li>Page 4</li>
<li>Page 5</li>
<li>Page 6</li>
<li>Page 7</li>
<li>Page 8</li>
<li>Page 9</li>
<li>Page 10</li>
<li>Page 11</li>
<li>Page 12</li>
<li>Page 13</li>
<li>Page 14</li>
</ul>
</div>
我将此代码转移到了sample.html 上,但情况确实如此。当我在本地主机上运行 jquery 时,它无法工作。但是当我打开时 - > Google Chrome 的sample.html 文件支持jquery 工作。我认为问题不在代码中。当我通过本地主机运行文件时,即使它是 .html 或 .php 文件,也会出现问题。请帮助我T_T
当我通过本地主机运行代码时,会生成此输出
第1页第2页第3页第4页第5页第6页第7页第8页第9页第10页第11页第12页第13页第14页
但是当我直接运行它时浏览器打开方式 -> 浏览器 这是输出
Page 1 Page 2 Page 3 Page 4 Page 5
1 2 3 Next
at first i ran this code on php file and run it on localhost using WampServer. the pagination didn't work so i tried to convert it to html file ("sample.html"). the code here as follows.
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="js/easypaginate.js"></script>
<script type="text/javascript">
jQuery(function($){
$('ul#items').easyPaginate({
step:5
});
});
</script>
<style>
#page li {
display: inline;
position: relative;
width: 11em
margin:10px;
padding:10px;
}
#page li li{ display: block; height: 1.5em;}
</style>
<div id = "page">
<ul id="items">
<li>Page 1</li>
<li>Page 2</li>
<li>Page 3</li>
<li>Page 4</li>
<li>Page 5</li>
<li>Page 6</li>
<li>Page 7</li>
<li>Page 8</li>
<li>Page 9</li>
<li>Page 10</li>
<li>Page 11</li>
<li>Page 12</li>
<li>Page 13</li>
<li>Page 14</li>
</ul>
</div>
i transferred this code on sample.html but the case is. the jquery is not working when i ran it on localhost. but when i Open With - > Google Chrome the sample.html file the jquery work. I think the problem is not in the code. the problem occured when i ran the file via localhost even if it is a .html or .php file. help me please T_T
when i ran the code through localhost this output is produced
Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 Page 9 Page 10 Page 11 Page 12 Page 13 Page 14
but when i ran it directly on a browser Open With -> Browser
this is the output
Page 1 Page 2 Page 3 Page 4 Page 5
1 2 3 Next
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查 PHP 生成的任何错误的来源。看来你在服务器端做了一些无效的事情。
http://jsfiddle.net/Zu3Ae/
check the source for any errors generated by PHP. it seems you are doing some invalid things in your server side.
http://jsfiddle.net/Zu3Ae/
请记住,JavaScript 是在客户端运行的,因此文件的提供位置没有区别。这让我相信相关文件没有被提供。
恕我直言,你最好的选择是在你的 html 中添加一个
href 标签。例如,在该示例中,假设您有一个包含 JavaScrpt 文件的目录
js
,并且该 js 目录位于您的目录SouthSapphire2
内。Remember that JavaScript is run client side, so where the files are served from makes no difference. Which leads me to believe the relevant files are not being served.
Your best bet, imho, is to add a
<base>
href tag to your html. e.g.In that example, the presumption is that you have a directory
js
that has your JavaScrpt files, and that that js directory is sitting inside your directorySouthSapphire2
.