我试图在许多地方遍历DOM,替换一些内容。
jQuery(\'.homepage_buttons_text a[href^="http://danrobertsgroup.com/?attachment_id=1037"]\').each(function(){
jQuery(this).html("<h1 class=\'homepage_button_title\'>Workouts</h1><span class=\'homepage_button_title\'>Books / DVD\'s / Downloads</span>");
});
在控制台中执行此操作时效果很好,但在脚本文件中执行此操作时效果不佳。我正在运行一个儿童主题并正确排队,我认为:
function child_theme_enqueue_scripts() {
wp_enqueue_script(
\'child-scripts\',
get_stylesheet_directory_uri() . \'/js/child-scripts.js\',
array( \'jquery\' ),
\'1.0\',
true
);
}
add_action( \'wp_enqueue_scripts\', \'child_theme_enqueue_scripts\' );
一切都很好。我甚至调用了子脚本。js在页脚和最后一个位置,但仍然没有乐趣。这很烦人,任何帮助都很感激。