【问题标题】:Using Jquery $(this) in Meteor在 Meteor 中使用 Jquery $(this)
【发布时间】:2012-07-31 00:28:54
【问题描述】:

如何在流星中使用这个功能?例如,我希望能够点击任何给定的

元素并找出它的类是什么。另外,我如何获取有关我使用 Meteor 点击的项目的信息?

【问题讨论】:

    标签: javascript jquery this meteor self


    【解决方案1】:

    假设在代码的某处你有一个模板处理事件:

    Template.tmpl_name.events = {
      'click #logo': function (e) {
        // Instead of using $(this), you can do:
        var $this = $(e.target);
        // Your usual code here, e.g.:
        console.log($this.attr('href'));
      }
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-27
      • 2013-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-21
      • 1970-01-01
      • 2010-09-19
      相关资源
      最近更新 更多