I want to select all links that a direct child of a table cell, so I have the following selector:
$('td a')
But I want to add another filter to this. I only want to select those table cell links that have a direct sibling with a class of 'moda'. In other words, the following will match:
<td>
<a data-target="#unresolvedTasks" data-toggle="modal" href="#" style="">dfsgdfg fghfghjhgj</a>
<div class="modal fade" id="unresolvedTasks" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</td>
I did a google search about AND conditions, which gave me this link. But this is a different type of AND condition:
a=$('[myc="blue"][myid="1"][myid="3"]');
That will select an element that meets all those criteria. I want to select an element that meets a specific criteria and then also check if its sibling meets a specific criteria.
I tried this:
$('td a, td a + div[class="modal"]')
But that is doing an OR condition not an AND condition.
Any suggestions?
答案 0 :(得分:0)
try to use
$('td > div.modal').prev('a')
and if you want to loop through them
$('td').each(function(){
console.log($(this).find('div.modal').prev('a').attr('data-target'));
});
答案 1 :(得分:0)
result = [{quote.id:quote.qualification_set.all()} for quote in Quote.objects.all()]