【发布时间】:2015-08-22 06:51:34
【问题描述】:
小提琴 - http://codepen.io/mikethedj4/pen/BNRdVp
今天我决定学习 Coffeescript 并尝试制作一些函数,处理事件等。
但是今天我遇到了一个错误,上面写着“保留字'功能'”,并且还没有想出如何解决它。
原文:
$(function () {
function download_to_textbox(url, el) {
$.get(url, null, function (data) {
el.val(data);
}, "text");
}
download_to_textbox("http://code.jquery.com/jquery-latest.min.js", $("textarea"));
});
我的翻译:
(($) ->
function download_to_textbox(url, el) {
$.get(url, null, (data) ->
el.val(data);
}, "text");
}
download_to_textbox("http://code.jquery.com/jquery-latest.min.js", $("textarea"));
$("textarea").click ->
$(this).select();
) jQuery
【问题讨论】:
-
CS中没有
function关键字。
标签: javascript jquery ajax coffeescript