MeteorJS: How to get clicked element

前端 未结 2 1313
慢半拍i
慢半拍i 2021-01-20 16:59

I\'m trying to get the clicked element so that I can add class. Does Meteor provides any way to get the current element like jQuery $ (this)

Template.retrain         


        
相关标签:
2条回答
  • 2021-01-20 16:59

    To get the element on which the event occurred, use event object.

    event.target
    

    As you've jQuery included, you can wrap the element in jQuery to use jQuery methods on it.

    $(event.target)
    

    You can see this in Meteor Tutorial

    0 讨论(0)
  • 2021-01-20 17:26

    From this you can get textbox value with one button click event.

    Try this:

    Template.retraining.events({
    'click .myclass':function(e,t){
     var val = t.find(".classname").value;
    }
    
    0 讨论(0)
提交回复
热议问题