###やりたいこと
PCのホバー効果をスマホで要素タッチ〜他の要素がタッチされるまで実行
###コード
jquery
1jQuery(function($){ 2document.getElementById('wrap')[0].setAttribute('ontouchstart',''); 3 var touch = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 4 if (touch) { 5 try { 6 for (var si in document.styleSheets) { 7 var styleSheet = document.styleSheets[si]; 8 if (!styleSheet.rules) continue; 9 for (var ri = styleSheet.rules.length - 1; ri >= 0; ri--) { 10 if (!styleSheet.rules[ri].selectorText) continue; 11 if (styleSheet.rules[ri].selectorText.match(':hover')) { 12 //styleSheet.deleteRule(ri); 13 styleSheet.rules[ri].selectorText = styleSheet.rules[ri].selectorText.replace(':hover', ':active'); 14 } 15 } 16 } 17 } catch (ex) {} 18 } 19 });
###エラーの内容
uncaught typeerror cannot read property'null' of null
wrapの閉じ括弧から赤い波下線がひかれています。
###補足
なげやりな質問内容になってしまっていたらすみません。
js初心者なので、マナーとかよくわかっておらず、本来なら基礎から勉強して一つずつ解析すべきなのかとは思いますが、急ぎで解決しなければならなかったため、こちらでお力をお借りさせていただくことにしました。
どうぞよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/11/18 22:37
2020/11/20 03:53