저는 만들고있는 wp 플러그인에 jquery를 구현하려고합니다. 내 테마의 functions.php에서 jQuery와 Wordpress - 스크립트가 작동하지 않습니다.
나는 다음과 같은 코드가 있습니다 I 출력 기능과 ADD_ACTION ('wp_head', 'functions_name')를 통해 다음과 같은 플러그인 파일 중 하나에서 다음function load_jquery() {
// only use this method is we're not in wp-admin
if (!is_admin()) {
// deregister the original version of jQuery
wp_deregister_script('jquery');
wp_deregister_script('jquery-ui-slider');
wp_deregister_style('jquery-ui-style');
// discover the correct protocol to use
$protocol='http:';
if($_SERVER['HTTPS']=='on') {
$protocol='https:';
}
// register the Google CDN version
wp_register_script('jquery', $protocol.'//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', false, '1.10.2');
wp_register_script('jquery-ui-slider', $protocol.'//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js', false, '1.10.3');
wp_register_style('jquery-ui-style', $protocol.'//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css', false);
// add it back into the queue
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-slider');
wp_enqueue_style('jquery-ui-style');
}
}
add_action('wp_enqueue_scripts', 'load_jquery');
을 ;
echo '
<script type="text/javascript">
jQuery(function($) {
$("#slider-range").slider({
range: true,
min: 0,
max: 500,
values: [ 75, 300 ],
slide: function(event, ui) {
$("#amount").val("$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ]);
}
});
$("#amount").val("$" + $("#slider-range").slider("values", 0) +
" - $" + $("#slider-range").slider("values", 1));
});
</script>';
실제 스크립트 전에로드 된 jquery를 볼 수는 있더라도 아무 것도 작동하지 않습니다.
아이디어가 있으십니까? 내가 wp_enqueue_script 부분을 건너 뛰고, 모든 것을 지나친다면, 그것은 작동합니다.
무엇이 문제인가? 스크립트가 전혀로드되지 않았거나로드되었지만 작동하지 않습니다. –
원본 코드에서 볼 수 있도록 스크립트가로드되었지만 작동하지 않습니다. – Fred
Genesis 프레임 워크 btw를 실행하고 있습니다. – Fred