1

I have this selector

self = $('.trim .person:nth-child('+index+')');
self.append('<img src="'+element.profilePic+'" class="profilePic" />');

I then want to use this select a class within

  $(self + '.spacer').css('opacity', 0.5);

I also tried

self + $('.spacer').css('opacity', 0.5);

1 Answer 1

4

Set it as the context parameter in jQuery.

$('.spacer', self).css('opacity', 0.5);

Or use find() method to get element within the current jQuery object.

self.find('.spacer').css('opacity', 0.5);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.