デバッグしようとしていますが、構文エラーが発生し続けます。私はこれで何が起こっているのか分かりません。 "$ color_cell"にアタッチされているオブジェクトをクリックすると、atrr( "id")がblack_colors配列にプッシュされます。jQuery構文エラー - 予期しないトークン
誰かが私にこれを手伝ってもらえますか?前もって感謝します。
<script src="jquery-1.6.2.js"></script>
<script type="text/javascript">
var ids = [];
var black_colors = [];
var blue_colors = [];
var brown_colors = [];
var gray_colors = [];
var green_colors = [];
var orange_colors = [];
var pink_colors = [];
var purple_colors = [];
var red_colors = [];
var teal_colors = [];
var white_colors = [];
var yellow_colors = [];
$(document).ready(function($) {
$(".btnColor").click(function(){
$(".color_cell").click(function(){
if $(this).attr("id") == "black"{
black_colors.push($(this).attr("id"));
}
});
});
});
</script>
<br>
<br>
<button type="button" class="btnColor" id="black">Black</button>
<button type="button" class="btnColor" id="blue">Blue</button>
<button type="button" class="btnColor" id="brown">Brown</button>
<button type="button" class="btnColor" id="gray">Gray</button>
<button type="button" class="btnColor" id="green">Green</button>
<button type="button" class="btnColor" id="orange">Orange</button>
<button type="button" class="btnColor" id="pink">Pink</button>
<button type="button" class="btnColor" id="purple">Purple</button>
<button type="button" class="btnColor" id="red">Red</button>
<button type="button" class="btnColor" id="teal">Teal</button>
<button type="button" class="btnColor" id="white">White</button>
<button type="button" class="btnColor" id="yellow">Yellow</button>
だけ最後のものは本物ですエラー。 HTML5のデフォルトのスクリプト言語はJavaScriptです(これはHTML5かどうかわかりません)。また、jQueryはレディハンドラの最初の引数として自身への参照を渡します。 –