フィドルでコーディングしたカスタム js を使用しており、それを自分のワードプレス テーマに統合したいと考えています。以下のように登録スクリプトとエンキュー スクリプトを使用しましたが、正しくロードされているように見えますが、それは custom.js です。エラーになっているようです。
私が立ち往生しているので、タグや何かを見逃した場合は、誰かが私に知らせてください. 以下は私のコードです: -
/私の関数ファイル/
<?php
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") ."://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
wp_enqueue_script('jquery');
wp_register_script( 'jquery-ui', get_template_directory_uri().'/js/jquery-ui.min.js', array('jquery'), true );
wp_enqueue_script( 'jquery-ui' );
wp_register_script( 'custom', get_template_directory_uri().'/js/custom.js', array('jquery-ui'), true );
wp_enqueue_script( 'custom' );
}
?>
/私のカスタム JS ファイル* /
$(document).ready(function() {
$("h1, h2").on('click', function (e) {
e.preventDefault();
$(this).effect( "bounce", { times : 2, direction : "down", distance : "3" }, 200)
});
ありがとうカースティ