gpt4 book ai didi

jQuery CoffeeScript - 学习

转载 作者:行者123 更新时间:2023-12-01 03:19:53 27 4
gpt4 key购买 nike

我正在尝试将 jQueryCoffeScript 一起使用。我按照博客中的说明操作,指示使用 $ ->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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com