在 Jquery 选择器中附加变量
Apending variable in Jquery selector
我有这个select或
self = $('.trim .person:nth-child('+index+')');
self.append('<img src="'+element.profilePic+'" class="profilePic" />');
然后我想在
中使用这个 select 一个 class
$(self + '.spacer').css('opacity', 0.5);
我也试过了
self + $('.spacer').css('opacity', 0.5);
设置为context parameter in jQuery。
$('.spacer', self).css('opacity', 0.5);
或者使用find()
方法获取当前jQuery对象中的元素。
self.find('.spacer').css('opacity', 0.5);
我有这个select或
self = $('.trim .person:nth-child('+index+')');
self.append('<img src="'+element.profilePic+'" class="profilePic" />');
然后我想在
中使用这个 select 一个 class $(self + '.spacer').css('opacity', 0.5);
我也试过了
self + $('.spacer').css('opacity', 0.5);
设置为context parameter in jQuery。
$('.spacer', self).css('opacity', 0.5);
或者使用find()
方法获取当前jQuery对象中的元素。
self.find('.spacer').css('opacity', 0.5);