Michael Heitz
Michael Heitz

Reputation: 3

Jquery function should work with subclasses, not for all classes

A have a this jquery function....

$(".rolled-wrap").on('click', function() {
     $(this).each(function() {
        $('.button-text span').text($('.button-text span').data('hover'));
        $('.button-text span').attr("data-hover", $('.button-text span').data('hover'));
    });
}); 

this function need working only for subclasses, current .rolled-wrap (e.g. .rolled-wrap (this) .button-text span)..... however clicking on one class, result summbit for all .button-text span.... I do not know what to do, I will be grateful for any help. thank you in advance

Upvotes: 0

Views: 31

Answers (1)

WillD
WillD

Reputation: 6512

To look inside the target element use .find()

$(".rolled-wrap").on('click', function() {
     $(this).find('.button-text span').text($('.button-text span').data('hover'));
     $(this).find('.button-text span').attr("data-hover", $('.button-text span').data('hover'));
}); 

Upvotes: 1

Related Questions