LPを模写してコーディングを勉強中なのですがslideToggle()が反映されません。
発生している問題・エラーメッセージ
Uncaught TypeError: $answer.slideToggle is not a function at HTMLParagraphElement.<anonymous> (style.js:5) at HTMLParagraphElement.dispatch (jquery-3.3.1.slim.min.js:2) at HTMLParagraphElement.v.handle (jquery-3.3.1.slim.min.js:2) (anonymous) @ style.js:5 dispatch @ jquery-3.3.1.slim.min.js:2 v.handle @ jquery-3.3.1.slim.min.js:2
該当のソースコード
HTML
1<!doctype html> 2<html lang="en"> 3<head> 4 5 <!-- Required meta tags --> 6 <meta charset="utf-8"> 7 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 8 9 <!-- Bootstrap CSS --> 10 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> 11 <link rel="stylesheet" href="./css/style.css" /> 12 13 <script src="https://code.jquery.com/jquery-1.10.2.js"></script> 14 <script type="text/javascript" src="./style.js"></script> 15 16 <title>iSara</title> 17 18</head> 19 20<body> 21<div class="background-thinpink"> 22 <div class="flex3 pinkheader"> 23 <p class="font-weight-bold">∨</p> <!-- 押す場所--> 24 </div> 25 <div class="hidden"><!--隠す場所--> 26 <p>出発前の1ヶ月前に事前課題を送ります。</p> 27 </div> 28</div> 29</body> 30</html> 31
jQuery
1$(function () { 2 3 $(".flex3 p").click(function () { 4 var $answer = $(this).parent().parent().find(".hidden"); 5 $answer.slideToggle(); 6 }) 7 8 9}) 10
試したこと
jQueryはslim版ですと、アニメーションに関する関数が使えないと調べて分かったので
slimではないCDNを使ってみたのですが
エラーメッセージにはslim使ってますよー風なメッセージがでてくるので困惑しています。
CDNで読み込むとすべてslim版になってしまうのでしょうか
それともほかに何か原因があるのでしょうか
ご教授願います。
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。