2012-05-16 2 views
-4

편집 : 나는 jquery 라이브러리를로드하고있다. 나는 jQuery가 JavaScript를 가져올 필요가 없다고 생각했다. noobish 질문으로 시간을 낭비해서 죄송합니다.jQuery가 작동하지 않습니다. | Wordpress 톱 메뉴

//

6으로 톱 메뉴의 표시 (호버 효과) 수정 jQuery를 사용하여이 작동 워드 플러그인.

내가 원하는 것은 플러그인의 필요성을 제거하면서 테마의 기능을 구현하는 것입니다. 나는 <head> 섹션에서이 부분을

<script type="text/javascript"> 
    jQuery(document).ready(function($) { 
    $('#access li').mouseover(function() { 
    $(this).find('ul').show(); 
    }); 
    $('#access li').mouseleave(function() { 
    $(this).find('ul').hide(); 
    }); 
    $('#access li ul').mouseleave(function() { 
    $(this).hide(); 
    }); 
    }); 
    </script> 

를 넣어 경우

오류 나는 점점되었다 내가 가장 가능성이 문제가 JS가로드되기 전에 내 코드가 실행되는 것을 발견 Uncaught ReferenceError: jQuery is not defined했다.

나는 웹에서 발견 솔루션을 사용하고이

$(document).ready(function() { 
    //my code here 
}); 

에 내 코드를 감싸 그리고이 두 가지 오류를 얻고 있었다 out.Now을 시도했다.

Uncaught ReferenceError: $ is not defined 
Uncaught ReferenceError: jQuery is not defined 

오류보고 후에는 왜 내가 jQuery를 작동 생각 나는 그것이 http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js에서로드 jQuery 라이브러리로 작업있어

//

를 작동하지 않도록하십시오 여전히 더 명확하지만입니다 아무것도 가져올 필요없이 자바 스크립트와 같은; D

워드 프레스 플러그인 소스 코드 :

<?php 
/** 
* Plugin Name: Twentyten IE6 Menus 
* Author: Sara Cannon 
* Author URI: http://sara-cannon.com 
* Description: Make the menu drop down in IE6 (if you care about that sort of thing) 
* Version: 1.0 
* License: GPL2 
*/ 
function sara_twentyten_ie6_menus_enqueue() { 
wp_enqueue_script('jquery'); 
} 
add_action('after_setup_theme', 'sara_twentyten_ie6_menus_enqueue'); 

function sara_twentyten_ie6_menus_script() { 
?> 
<!--[if lte IE 6]> 
<script type="text/javascript"> 
jQuery(document).ready(function($) { 
$('#access li').mouseover(function() { 
$(this).find('ul').show(); 
}); 
$('#access li').mouseleave(function() { 
$(this).find('ul').hide(); 
}); 
$('#access li ul').mouseleave(function() { 
$(this).hide(); 
}); 
}); 
</script> 
<![endif]--> 
<?php 
} 
add_action('wp_footer', 'sara_twentyten_ie6_menus_script'); 
+0

방화 광의 JS 오류가 발생 했습니까? jQuery를 수동으로 연결하고 있습니까? 이 질문은 엉망입니다. – Bosworth99

답변

0

jQuery는 .ready (function() {})에 아무 것도 전달하지 않습니다. u는 제대로 jQuery를 수입하는 경우 ($)가 정의되지 안이 블록 jQuery를 내부

(function($, window, document, undefined) { 
     $(function() { 
     $('#access li').mouseover(function() { 
     $(this).find('ul').show(); 
     }); 
     $('#access li').mouseleave(function() { 
     $(this).find('ul').hide(); 
     }); 
     $('#access li ul').mouseleave(function() { 
     $(this).hide(); 
     }); 
     }); 
    })(jQuery, window, document); 

:

이 시도.

관련 문제