这对我没有意义,因为标题说我的jQuery在清除缓存后没有在第一次加载时运行,但如果我再次刷新页面这次不清除缓存它就可以工作。我正在一个WordPress网站上工作,我已将我的js包含在函数文件中,这是我js的所有代码。
function enqueue_my_scripts() {
wp_enqueue_script( 'alliance_script', get_template_directory_uri() . '/js/script.js');
wp_enqueue_script('slick_js', get_template_directory_uri() . '/slick/slick.min.js');
}
add_action('wp_enqueue_scripts', 'enqueue_my_scripts');
jQuery(document).ready(function(){
/*positioning the footer*/
var nav_cont = jQuery("#hd_ft_cont").height();
var header = jQuery("#main_nav").height();
var footer = jQuery("#footer").height();
var position = nav_cont - header - footer;
jQuery("#footer").css("top", position);
/*setting padding on content equal to width of the nav to avoid overlay*/
var nav_width = jQuery("#hd_ft_cont").outerWidth();
jQuery(".page_cont_wrapper, .head").css("paddingLeft", nav_width);
jQuery(window).resize(function(){
var nav_width = $("#hd_ft_cont").outerWidth();
jQuery(".page_cont_wrapper, .head").css("paddingLeft", nav_width);
});
jQuery(".carousel").css("paddingLeft", nav_width);
jQuery(window).resize(function(){
var nav_width = jQuery("#hd_ft_cont").outerWidth();
jQuery(".carousel").css("paddingLeft", nav_width);
});
});