2017-03-17 8 views
0

jQueryの機能が動作していない2つの単純なページがありますが、最初のページは別のページを置く前に正常に機能していました。 - Win7のHTML jQuery - JSが動作しない単純な2ページ?

のindex.php

<!DOCTYPE html> 
<html> 
    <head> 
     <title> Home</title> 
     <meta charset="utf-8"> 
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
     <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> 
    </head> 
    <body> 
    </body> 
    <script src="https://code.jquery.com/jquery-3.2.0.min.js"></script> 
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
     <script src="js/js.js"></script> 
</html> 

jQueryのjs.js上のWAMP:

$(document).ready(function() { 
    alert('page1'); 
}); 

page2.php

<!DOCTYPE html> 
<html> 
    <head> 
     <title>eee</title> 
     <meta charset="utf-8"> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
     <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> 
    </head> 

    <body> 
     <script src="https://code.jquery.com/jquery-3.2.0.min.js"></script> 
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
     <script src="js/js_page2.js"></script> 
    </body> 
</html> 
あなたは、2ページへのjsファイルをリンクし、それをリンクし、すべてが期待どおりに動作するのを忘れ

js_page2.js

$(document).ready(function() { 
    alert('page2'); 
}); 
+1

コンソールでエラーが見つかりましたか? – Rayon

+0

警告またはポップアップブロック通知なしの空白ページなし –

+1

ブラウザに 'Developer Tool(F12)'のオプションがあり、 'console'タブが見つかりました。 – Rayon

答えて

1

+0

質問が既に追加されていることがわかりました: '' –

+0

すでに追加されています。 – user7417866

+0

jsファイルが正しいフォルダにない場合を除いて、コードに問題はなく、完全に動作するはずです。 –

0

javascriptファイルへの正しいパスを使用していることを確認してください。そうでない場合、コードは正しく表示されます。

コードをフィドルに貼り付けるだけで、インポートの代わりにjQueryを使うだけで問題ありません。

関連する問題