我对 jquery 很陌生,请帮助我在 this link 上运行该应用程序。我已在我的应用程序中添加了以下资源文件,但它仍然没有渲染颜色 block 。
这些是我在 head 标签中包含的内容:
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css"/>
<script src="http://code.jquery.com/jquery-1.6.4.min.js" type="text/javascript"/>
<script src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js" type="text/javascript"/>
<script src="jquery.mobile.carousel.js" type="text/javascript" language="javascript"/>
<script src="jquery.ui.ipad.js" type="text/javascript" language="javascript"/>
<script type="text/javascript" language="javascript" >
$(document).ready(function($) {
$("#carousel1").carousel();
})(jQuery);
</script>
最佳答案
你有:
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css"/>
<script src="http://code.jquery.com/jquery-1.6.4.min.js" type="text/javascript"/>
<script src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js" type="text/javascript"/>
<script src="jquery.mobile.carousel.js" type="text/javascript" language="javascript"/>
<script src="jquery.ui.ipad.js" type="text/javascript" language="javascript"/>
<script type="text/javascript" language="javascript" >
$(document).ready(function($) {
$("#carousel1").carousel();
})(jQuery);
</script>
我的建议是:
- Upgrade jQM to the latest version因为您使用的是 Remote
- 按照 @MarkRhodes 的建议正确关闭标签
- 按照@feco的建议更新框架的链接
- Use
pageInit()
, not$(document).ready()
可能看起来像:
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<!-- I'm asuming this is where you are getting these from -->
<!-- https://github.com/blackdynamo/jQuery-Mobile-Carousel -->
<script src="jquery-ui-1.8.7.custom.min.js" type="text/javascript" language="javascript"></script>
<script src="jquery.mobile.carousel.js" type="text/javascript" language="javascript"></script>
<script src="jquery.ui.ipad.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript" >
$('#pageId').live('pageinit',function(event){
$("#carousel1").carousel();
});
</script>
关于JQuery 代码不运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9126297/