Reputation: 109
I am trying to toggle my class once clicked but i am having trouble doing so - if anyone can point out what i am missing or doing wrong that would be great.
<a class="rGroupIcons icon-plus addUsersToGroup float_right" href="#" data-bind="attr: { 'data-user-id': ID()}"></a>
<div class="Roles fade in" data-bind="foreach: $parent.Roles()">
<a style="display: none;" class="roleType btn addUsersWithGroupRole" data-bind="text: RoleTypeName, attr: { 'data-roletype-id': RoleId() }"></a>
</div>
Javascript
$(document).on('click', '.addUsersToGroup', function (event) {
$(".addUsersToGroup", $(this)).toggleClass("icon-plus icon-minus");
});
Upvotes: 0
Views: 68
Reputation: 10258
You just need to use $(this) as at the moment you are looking for .addUsertsToGroup within the element addUsertsToGroup
$(document).on('click', '.addUsersToGroup', function (event) {
$(this).toggleClass("icon-plus icon-minus");
});
Working example here http://jsfiddle.net/domjgreen/NLYNK/
Upvotes: 1