-1

何らかの理由で、jQuery と Javascript が私のサイトで動作しません。

ここを参照してください: http://hellomynameisad.am/test.html

誰かがピークを迎えて、私が欠けているものを教えてもらえますか? jQueryのさまざまなスニッパーを試しましたが、何も機能しないようです。ありがとうございました。

4

2 に答える 2

3

html 要素を javascript にして実行するには、document.ready に配置する必要があります。または、body の終了タグの直前にスクリプトを配置することもできます。

ライブデモ

$(document).ready(function(){
  $("#container").fadeOut(function() {
     $(this).text("World").fadeIn();
  });
});

編集:以下のような html の他のいくつかの間違いを見つけました。

  1. 開始ボディタグはありません。
  2. head タグの間、または body タグを閉じる直前に script を挿入します。
  3. タイプ属性を JavaScript スクリプト タグに追加します。
  4. jquery の URL の前に http を付けたほうがよいでしょう:

HTML を変更する

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js"></script>
      <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.js ">     </script>
      <title>Untitled Document</title>
      <style type="text/css"> </style>

<script type="text/javascript">

    $(document).ready(function(){
        $("#container").fadeOut(function() {
            $(this).text("World").fadeIn(); 
        });
    });    
</script>    
</head>
<body>
    <div id="container">Hello</div>​
</body>
</html>
于 2013-01-04T04:33:27.953 に答える
-3

これを追加してください

<script>
  $(document).ready(function(){
     $("#container").fadeOut(function() {
        $(this).text("World").fadeIn();
     });
  });
</script>

コードの一部が</body>終了し、実行されることを確認します。

于 2013-01-04T04:47:00.907 に答える