如何使用jQuery包装集扩展类?

如何使用jQuery包装集扩展类?,jquery,coffeescript,Jquery,Coffeescript,下面的内容几乎有效 $el = -> $el:: = $ '#test' new class extends $el constructor: -> @append '<h1>Worked!</h1>' # this will overflow the stack @find('[role=test2]').append '<h2>Also Worked!</h2>' $el=-> $el::=$“#测

下面的内容几乎有效

$el = ->
$el:: = $ '#test'
new class extends $el
  constructor: ->
    @append '<h1>Worked!</h1>'


    # this will overflow the stack
    @find('[role=test2]').append '<h2>Also Worked!</h2>'
$el=->
$el::=$“#测试”
新类扩展$el
构造函数:->
@“成功了!”
#这将使堆栈溢出
@查找(“[role=test2]”)。追加“也有效!”

示例:

答案就在我面前

new class
  @:: = $ '#test'
  constructor: ->
    @append '<h1>Worked!</h1>'
    @find('[role=test2]').append '<h2>Also Worked!</h2>'
新类
@:=$“#测试”
构造函数:->
@“成功了!”
@查找(“[role=test2]”)。追加“也有效!”