我在我的jquery上使用了每个函数,在我的父函数中我的每个函数中都将其命名为this。我想查看班级list-item
中的班级 $('.list-item').each(function(){
if($(this).text().toUpperCase().indexOf(txt.toUpperCase()) != -1){
$('.list-item').show();
}
});
<li class="list-item">
some data <span class="name">this data</span>
</li>
。但我目前的代码显示了这一点:
.list-item
我应该更改条件语句,以检查我的.list-item
内的类名而不是整个with
users ( id, user_name ) as (
select 1, 'Bob' from dual union all
select 2, 'Joe' from dual union all
select 3, 'Mary' from dual
),
project_users ( user_id, project_id, access_type ) as (
select 1, 123, 8 from dual union all
select 1, 456, 9 from dual union all
select 1, 789, 10 from dual union all
select 2, 123, 10 from dual union all
select 2, 456, 9 from dual union all
select 2, 789, 8 from dual union all
select 3, 123, 9 from dual union all
select 3, 456, 10 from dual union all
select 3, 789, 10 from dual
)
-- End of test data (not part of the SQL query).
-- Query begins below this line.
select project_id,
listagg(user_name || '-' || to_char(access_type), ',')
within group (order by user_name) as comma_sep_list
from users u join project_users p on u.id = p.user_id
group by project_id
;
PROJECT_ID COMMA_SEP_LIST
---------- --------------------
123 Bob-8,Joe-10,Mary-9
456 Bob-9,Joe-9,Mary-10
789 Bob-10,Joe-8,Mary-10
3 rows selected.
内容?
答案 0 :(得分:1)
试试这个
$('.list-item').each(function(){
if($(this).find('.name').text().toUpperCase().indexOf(txt.toUpperCase()) != -1){
$(this).show();
}
});
答案 1 :(得分:1)
如果我正确阅读您的帖子,您希望使用$.find()
来获取.name
文字。而且您可能还希望在循环内部显示$(this)
,而不是所有.list-item
。
$('.list-item').each(function() {
var nameText = $(this).find('.name').text();
if (nameText.toUpperCase().indexOf(txt.toUpperCase()) != -1) {
$(this).show();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li class="list-item">
some data <span class="name">this data</span>
</li>
答案 2 :(得分:0)
也许尝试使用.find()
$('.list-item').each(function(){
if($(this).find('.name').text().toUpperCase().indexOf(txt.toUpperCase()) != -1){
$('.list-item').show();