我有这段代码用于加载内容以comment-list
div
使用 jQuery 进行分页delegate
:
JS:
<script type="text/javascript">
$('#comment-list .pagination a').delegate('click', function() {
$('#comment-list').fadeOut('slow');
$('#comment-list').load(this.href);
$('#comment-list').fadeIn('slow');
return false;
});
$('#comment-list').load('index.php?route=simple_blog/article/comment&simple_blog_article_id=<?php echo $simple_blog_article_id; ?>');
</script>
HTML:
<div id="comment-list">
<div class="pagination">
<div class="links">
<b>1</b>
<a href="http://localhost/oc/index.php?route=simple_blog/article/comment&simple_blog_article_id=5&page=2">2</a>
<a href="http://localhost/oc/index.php?route=simple_blog/article/comment&simple_blog_article_id=5&page=3">3</a>
<a href="http://localhost/oc/index.php?route=simple_blog/article/comment&simple_blog_article_id=5&page=2">></a>
<a href="http://localhost/oc/index.php?route=simple_blog/article/comment&simple_blog_article_id=5&page=3">>|</a> </div><div class="results">Showing 1 to 5 of 11 (3 Pages)
</div>
</div>
</div>
但在行动中,我的代码无法正常工作,也无法将内容加载到div
. 点击分页链接后,我看到打开新窗口并加载我的内容。jQuery 2.1.1
我在Version中测试我的代码,我认为delegate
在jQuery 2.1.1
.
如何解决我的问题?