Reputation: 6554
$(document).ready(function() {
var $postBG = $('.post .poster-profile img');
$postBG.find("[title='male']")
.closest('tr')
.addClass('male')
.children('td')
.removeClass('row1 row2');
$postBG.find("[title='female']")
.closest('tr')
.addClass('female')
.children('td')
.removeClass('row1 row2');
});
Just trying to find if the img title is female or male, and then do the following codes above. I tried
$postBG.attr("male")
that did not work though any help please
Upvotes: 0
Views: 50
Reputation: 144689
find
finds the elements within the context of the selected element, you can use filter
method:
var $postBG = $('.post .poster-profile img');
$postBG.filter('[title="male"]').foo()
or attribute
selector instead:
var $postBG = $('.post .poster-profile img[title="male"]');
Upvotes: 1