想在页面直接加载js文件,js应放在哪里
2011-12-15 22:35
260 查看
看我写的第一个代码
始终没有效果,最后把script文件放在body最后,终于可以了。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"> </script> </head> <body>
<script> $('p:nth-child(odd)').css("background","red"); $('p:nth-child(even)').css("background","green"); </script>
<p>we can we can</p> <p>we can we can</p> <p>we can we can</p> <p>we can we can</p> <p>we can we can</p> <p>we can we can</p> <p>we can we can</p> <p>we can we can</p> </body> </html>
始终没有效果,最后把script文件放在body最后,终于可以了。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"> </script> </head> <body>
<p>we can we can</p>
<p>we can we can</p>
<p>we can we can</p>
<p>we can we can</p>
<p>we can we can</p>
<p>we can we can</p>
<p>we can we can</p>
<p>we can we can</p>
<script> $('p:nth-child(odd)').css("background","red"); $('p:nth-child(even)').css("background","green"); </script>
</body>
</html>
相关文章推荐
- asp.net使用httphandler打包多CSS或JS文件以加快页面加载速度
- JS脚本文件的位置对页面加载性能影响以及无阻塞脚本(javascript)模式
- asp.net使用httphandler打包多CSS或JS文件以加快页面加载速度
- 向页面动态加载JS文件的的一个小技巧
- 判断一个页面是否加载了某个js文件
- ASP.NET 打包多CSS或JS文件以加快页面加载速度的Handler
- struts1的.do页面无法加载外部的js文件
- asp.net使用httphandler打包多CSS或JS文件以加快页面加载速度
- html页面异步加载js文件
- Wordpress不同页面判断加载头部JS CSS等文件
- 页面加载顺序及js文件的插入位置
- web页面优化之动态加载js和文件
- easy UI使用include<>包含页面时以及加载js文件所注意的事项。
- C# js 在页面能执行,放在单独js文件不能执行
- 关于js与css加载的理解,理解网页head标签中的JS和CSS,哪种文件放在前面,哪种放在后面比较好
- 关于jsp页面是放在webroot目录下和web-inf下优缺点/(如何访问WebRoot中的CSS和JS文件)
- springmvc配置后jsp页面不能加载css,js等静态文件
- 1将所有的js文件引入到taglibs.jsp中,以后再其他页面中直接引入这个jsp文件
- 使用SUI mobile 通过a标签跳转到新页面 js文件不加载问题
- 明明加载好了css,js文件,页面的样式还是不对的解决办法