下記index.htmlで「テスト」ボタンの表示、非表示に関して
PCではボタンが表示されるのですが、スマホでやるとボタンが消えたまま表示されません。
関数内のconsoleはちゃんとlogをはいています。
ちなみにindex.htmlのheder内に直接
<script> $(function(){ $(".auth1").css({'display':'block'}); }) </script>
と書くと動作(スマホでもボタンは表示される)します。
何が原因でしょうか?
スマホデバイス:iphone iOS11 safari
PC :Mac環境
index.html
<!DOCTYPE html> <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Language" content="ja"> <meta http-equiv="content-script-type" content="text/javascript"/> <meta http-equiv="content-style-type" content="text/css"/> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="robots" content="noimageindex"> <meta name="robots" content="noindex"> <title>タイトル</title> <link rel='stylesheet' type="text/css" href='css/style.css'/> <script type='text/javascript' src="js/jquery-2.1.4.min.js"></script> <script type='text/javascript' src='js/common.js'></script> </head> <body> <button class='auth1'>テスト</button> </body> </html>
style.css
.auth1{display:none;}
common.js
$(function(){ auth(); }) function auth(){ console.log('ok'); $(".auth1").css({'display':'block'}); }
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。