嵌套Javascript函数
我有两个javascript函数用于分页和截断,如下所示:嵌套Javascript函数,javascript,Javascript,我有两个javascript函数用于分页和截断,如下所示: <script type="text/javascript" src="//path/js/jquery.quick.pagination.min.js"></script> $("#post_list").quickPagination({ pagerLocation:"both", pageSize:"3" }); <script type="text/javascript" lang
<script type="text/javascript" src="//path/js/jquery.quick.pagination.min.js"></script>
$("#post_list").quickPagination({
pagerLocation:"both",
pageSize:"3"
});
<script type="text/javascript" language="javascript" src="//path/js/jquery.dotdotdot.js"></script>
$(".post_detail").dotdotdot({
after: 'a.more',
callback : function( isTruncated, orgContent ) {
if (!isTruncated) {
$('.more',this).remove()
}
},
});
您可以将这两个函数写在一个公共函数中,如下所示
$(function()
{
$("#post_list").quickPagination({
pagerLocation:"both",
pageSize:"3"
});
$(".post_title").dotdotdot();
$(".post_detail").dotdotdot({
after: 'a.more',
callback : function( isTruncated, orgContent ) {
if (!isTruncated) {
$('.more',this).remove()
}
},
});
});
你的解决方案看起来很直截了当,但我就是做不到。我添加了一个JSFIDLE。请看看这对我的问题是否有帮助
$("#post_list").quickPagination({
pagerLocation:"both",
pageSize:"3"
// ** optional function I want to include here **/
});
$(function()
{
$("#post_list").quickPagination({
pagerLocation:"both",
pageSize:"3"
});
$(".post_title").dotdotdot();
$(".post_detail").dotdotdot({
after: 'a.more',
callback : function( isTruncated, orgContent ) {
if (!isTruncated) {
$('.more',this).remove()
}
},
});
});