我试着在没有冲突的情况下修复代码,但它仍然不能在wordpress上运行。
更奇怪的是,同样的代码在jsbin上运行得很好。
http://jsbin.com/egezeg/1/edit
原码:http://cloud.github.com/downloads/wduffy/jScroll/jquery.jscroll.js
我还测试了
$j("body").html("1234");它工作得很好。
这里我漏掉了什么?
发布于 2013-03-13 06:47:44
尝试将如下内容添加到您的functions.php中:
//ad our custom Jquery
function my_init() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js', false, '1.8.2', true);
wp_enqueue_script('jquery');
// load a JS file from your theme: js/theme.js
wp_enqueue_script('myscript', get_template_directory_uri() . '/js/myscript.js', array('jquery'), '1.0', true);
}
}
add_action('init', 'my_init');https://stackoverflow.com/questions/15373111
复制相似问题