我正在尝试将 jQuery
与 CoffeScript
一起使用。我按照博客中的说明操作,指示使用 $ -> 或 jQuery -> 而不是 .ready() 。我玩了一下代码,但我似乎无法理解我出错的地方。只是想学习一点点。
这是在 jQuery
中运行的代码:
$(document).ready( function() {
$("span.today").closest("td").css("background-color", "#7792ad")
});
这是我期望在 CoffeScript
中工作的内容:
$ ->
$("span.today").closest("td").css("background-color", "#7792ad")
但它不起作用。
最佳答案
试试这个:
$ ->
$("span.today").closest("td").css("background-color", "#7792ad");
A general principle is that many unnecessary parentheses and braces can be dropped because indention can be used instead of braces to denote blocks of code
关于jQuery CoffeeScript - 学习,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11181787/