個人的な学習でWordPressを勉強しており、その中でタイピング風な動きを出してくれるTyped.jsを使用しようと考えました。
Typed.jsからファイルをダウンロードし、そちらを子テーマ内に保存しました。
そして呼び出しを行ったところ、下記のようなエラーとなりました。
Uncaught TypeError: $(...).typed is not a function at HTMLDocument.<anonymous> ((index):149) at i (jquery.js?ver=1.12.4:2) at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2) at Function.ready (jquery.js?ver=1.12.4:2) at HTMLDocument.K (jquery.js?ver=1.12.4:2)
Typed.jsが読み込まれていなく、typed
メソッドが呼ばれていないのかな、と予想はしたのですが、
そのあとのアクションが立てられません。。。
問題の切り分けなど、ご教授いただけないでしょうか?
下記に、functions.php
と、JSのファイルを記載します。
php
1<?php 2add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); 3function theme_enqueue_styles() { 4 wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); 5 wp_enqueue_script('typed', 6 get_stylesheet_directory_uri().'/assets/js/typed.js', 7 array('jquery'), false, false); 8 wp_enqueue_script('functions', 9 get_stylesheet_directory_uri().'/assets/js/functions.js', 10 array('typed'), false, false); 11} 12?>
js
1jQuery(document).ready(function($) { 2 $(".typed-element").typed({ 3 strings: ["テスト1", "テスト2"], 4 typeSpeed: 0, 5 startDelay: 0, 6 backSpeed: 0, 7 shuffle: false, 8 backDelay: 500, 9 loop: false, 10 loopCount: null, 11 showCursor: true, 12 cursorChar: "|" 13 }); 14});
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/26 14:58