基本上我試圖改變一些JQuery的背景顏色,將class =「cell」的div加入到class =「grid」的父級div中。因此,「細胞」類不是在原來的index.html
因此它可以定義當我寫這樣的代碼:
$(document).ready(function() {
var clr = "red";
$('.cell').mouseenter(function() {
$(this).css('background-color', clr);
});
});
但它不是我定義的功能等:
$(document).ready(function() {
function fillCell(clr){
$(this).css('background-color', clr);
}
$('.cell').mouseenter(function() {
alert(clr); //added for test
fillCell("red");
});
});
請注意,當懸停並觸發「紅色」時,警報()會被觸發。
'這個'不符合你的想法。 –
拜託,我錯過了什麼? – Ozilyo
http://stackoverflow.com/a/17514482/400654 –