0
我剛剛製作了一個新的wordpress主題,我正在使用以下腳本來獲得類似手風琴的效果。jQuery不適用於無限滾動
(function($) {
var $ele = $('.entry-content').hide();
$(".entry-header").click(function(e) {
e.preventDefault();
var $ele1 = $(this).parents(".post").children('.entry-content').slideToggle('fast');
$ele.not($ele1).slideUp();
});
})(jQuery);
我剛啓動了jetpack的infinite scroll。 jquery腳本不適用於通過無限滾動添加的新加載的內容。我的猜測是,無論何時通過無限滾動添加新內容,腳本都必須重新加載或至少被觸發。我一整天都在網上搜索,沒有找到任何解決方案。任何幫助在這裏將不勝感激。
我已經排隊我的.js文件在我的functions.php這樣的:
function journial() {
wp_enqueue_script('journial', get_template_directory_uri() . '/js/journial.js', array('jquery'), '1.0.0', true);
}
add_action('wp_enqueue_scripts', 'journial');
這沒有奏效。 「後加載」特定於無限滾動還是僅僅是一個例子? – Arete
特定於Jetpack。我只是從這個頁面的底部拉出代碼... https://jetpack.com/support/infinite-scroll/。你有錯誤嗎? –
我也讀過這篇文章,但它沒有說我應該把這個代碼放在哪裏。在我的jQuery腳本?在我的functions.php或在ajax.php ... – Arete