ui: {
        "feature": "a.mouse-event-f"
    },

    events: {
        "click @ui.feature": "select"
    },

    select: function() {
        this.ui.feature.find("div.item_number").addClass("item_number_green");
    },

There are several elements with class "mouse-event-f" and in my case the class "item_number_green" is being added to all of them. But I need to add this class only to the clicked element. Is it possible?

有帮助吗?

解决方案

The select function is passed an event parameter containing the target of the click event. You can use that parameter like this:

select: function( e ) {
    $(e.target).addClass("item_number_green");
},
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top