Max*_*Max 1 javascript jquery coffeescript
我正在尝试编写一个相当简单的"全选"功能,但我的javascript出错了.代码很简单,所以我只是发布它:
(function() {
$(function() {
var all_check_box;
all_check_box = '#tournament_league_127';
return $(all_check_box).change(function() {
return $('.leagueCheckBox').each(function() {
return this.prop("checked", true);
});
});
});
}).call(this);
Run Code Online (Sandbox Code Playgroud)
此代码由以下CoffeeScript生成:
$ ->
all_check_box = '#tournament_league_127'
$(all_check_box).change ->
$('.leagueCheckBox').each ->
this.prop("checked", true)
Run Code Online (Sandbox Code Playgroud)
但是,当我点击#tournament_league_127时,我收到以下错误:this.prop is not a function
.我不确定我做错了什么.任何帮助,将不胜感激.
this
指的是你需要的元素而不是jQuery对象,
return $(this).prop("checked", true);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
137 次 |
最近记录: |