dan*_*aba 1 html javascript jquery nivo-slider
我的index.php底部包含以下行:
<script type="text/javascript" language="javascript" src="class/jquery-1.4.3.min.js"> </script>
<script type="text/javascript" language="javascript" src="class/jquery.nivo.slider.pack.js"></script>
<script type='text/javascript' language='javascript'>
$(window).load(function() {
$('#slider').nivoSlider();
});
</script>
Run Code Online (Sandbox Code Playgroud)
问题在于$(window).load...
index.php的主体通过ajax调用更新onload,在匹配时提供div#slider.这使它nivoSlider()不执行.你有什么把戏让这件事有用的伎俩吗?我更喜欢非jquery方式,但在一天结束时,任何事情都有帮助.
非常感谢
在AJAX加载的回调中添加调用.
$('.something').load( 'http://www.example.com/foo', function() {
$(this).find('#slider').nivoSlider();
});
Run Code Online (Sandbox Code Playgroud)
使用代码的示例(对于正文):
$(function() { // run on document ready, not window load
$('#content').load( 'page.php?c=2&limit=5', function() {
$(this).find('#slider').nivoSlider();
});
});
Run Code Online (Sandbox Code Playgroud)
对于链接:
<!-- updates links like so -->
<a class='nav' href='page.php?category=art&limit=5&c=1'>art</a>
// in the same document ready function
$('a.nav').click( function() {
var $link = $(this);
$('#content').load( $link.attr('href'), function() {
$(this).find('#slider').nivoSlider();
$link.addClass('selected'); // instead of setting bg directly to #828282;
});
return false; // to prevent normal link behavior
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5833 次 |
| 最近记录: |