2016-07-26 20 views
1

私は与える。私はjsfiddleコードをDreamweaverに転送するときに動作するように見えないのですか?私は何かを簡単に欠けているに違いない?それはjsfiddleでうまく動作します。私はonloadとは対照的にready関数を追加しましたが、まだ動作していません。ドリームウィーバーに転送

$("document").ready(function() { 
 

 
     var h1 = $('div#greeting h1'); 
 

 
     h1.hide().contents().each(function() { 
 
     var words; 
 
     if (this.nodeType === 3) { 
 
      words = this.data.split(/\s+/).map(function(w) { 
 
      return '<span>' + w + '</span>'; 
 
      }).join(''); 
 
      $(this).replaceWith(words); 
 
     } else if (this.nodeType === 1) { 
 
      $(this).html($(this).html().split(/\s+/).map(function(w) { 
 
      return '<span>' + w + '</span>'; 
 
      }).join('')); 
 
     } 
 
     }); 
 

 
     h1.find('span').hide().each(function() { 
 
     if (!$.trim(this.innerHTML)) { 
 
      $(this).remove(); 
 
     } 
 
     }); 
 

 
     $('#start').on('click', function() { 
 
     h1.show().find('span').each(function(i, e) { 
 
      h1.queue(function(next) { 
 
      $.when($(e).fadeIn(150).fadeOut(150)).done(next); 
 
      }); 
 
     }); 
 
     }); 
 
     $('#stop').on('click', function() { 
 
     h1.finish(); 
 
     }); 
 
     $('#reset').on('click', function() { 
 
     h1.finish(); 
 
     });
.box { 
 
    border: 1px solid #E38E34; 
 
    background-color: #FFE7BF; 
 
    height: 150px; 
 
    -webkit-border-radius: 1px; 
 
    -moz-border-radius: 1px; 
 
    border-radius: 1px; 
 
} 
 
#title { 
 
    margin: 5px; 
 
    border-bottom: 1px solid #E38E34; 
 
    color: #C46908; 
 
    font-weight: bold; 
 
} 
 
#message { 
 
    margin: 5px; 
 
} 
 
h1 { 
 
    font-size: 50px; 
 
    text-align: center; 
 
}
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 

 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
 

 
    <link rel="stylesheet" type="text/css" href="styles.css"> 
 

 
    <title>TedsCode</title> 
 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 

 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> 
 

 
    <script type="text/javascript" src="speedread.js"></script> 
 
</head> 
 

 
<body> 
 
    <div class="box" /> 
 
    <div id="title"><span id="name">Title</span> 
 
    </div> 
 
    <div id="message" /> 
 
    <div id="greeting" /> 
 
    <input type="button" value="Read" id="start" /> 
 
    <input type="button" value="Stop" id="stop" /> 
 
    <input type="button" value="Reset" id="reset" /> 
 
    <h1><center>This is a test to see if this script displays one word at a time and functions correctly.</center></h1> 
 

 
</body> 
 

 
</html>

答えて

0

あなたはJSで構文エラーをHAVA。

私は何かにコメントします:add "});" to js、jqueryの冗長参照を削除します。

コードスニペットは、現在

+0

を閉じていないで、 Dreamweaverはエラーを示しているはずです。ありがとう、それはうまくいっています:) – user3457159

0

に動作します、私は二つのことを見ることができます: 1-なぜあなたは同じ時間1.9.1および2.1.0でのjQueryの2つのバージョンを使用していますか? 2では、あなたが貼り付けるコードを、$(「文書」)。レディ(関数(){ うわー適切

コンソールまたはネットワーク内の任意のエラーを受信して​​いますか?

+0

うわー、それはDreamweaverでエラーを表示していなかった。ありがとうございました。 – user3457159