javascript - 使用 $(this) 查询下一个相邻选择器

标签 javascript jquery

我如何将相邻的选择器“+”与 $(this) 一起使用。

我需要注释行的帮助//this doesn't work:

$(".ExpandCollapse").click(function () {
            if ($(this).nextUntil('.Collapsable').is(':visible'))
            {
                //this doesnt work 
                $(this + ".Collapsable").hide();
            }
            else
            {
                //this doesnt work
                $(this + ".Collapsable").show();
            }
        });

你能帮我一下吗?

非常感谢。

最好的问候。

何塞

最佳答案

使用next()

$(this).next(".Collapsable").hide();

或者简单地说:

$(this).next().hide();

关于javascript - 使用 $(this) 查询下一个相邻选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3413435/

相关文章:

jquery - 销毁 jQuery 自动完成功能

php - 使用 JSON 绘制具有多条线的单个 Google 折线图

javascript - 如果延迟超过 2147483648 毫秒,setTimeout 会立即触发

javascript - 使用下划线循环键值对象

javascript - onclick 函数的问题

jquery - 使用 pagebeforeshow jquery 跨多个页面执行一个函数

javascript - 使用 mmenu 修复 Bootstrap Modal

javascript - 重用 FileReader 时宽度和高度错误

javascript - 在jquery中计算字符串中的特殊字符

javascript - 在页面完全加载后获取 innerHTML