简体   繁体   English

用这个选择元素

[英]Selecting the element with this

I recently started study jQuery and developing a site, i have two dropbox elements with dropbox class. 我最近开始研究jQuery并开发了一个站点,我有两个具有dropbox类的dropbox元素。

<a href="#" class="dropbox">+</a>
<a href="#" class="dropbox">+</a>

I want the one that clicked slide down, but when i use the "this" selector the slide down doesn't work, can anyone help me explain why? 我想要一个单击向下滑动的按钮,但是当我使用“ this”选择器时,向下滑动不起作用,有人可以帮我解释一下原因吗?

//slideDown() Method
$(".dropbox").click(function(){
    $("this").hide().slideDown();
});

What you're looking for is this: 您正在寻找的是:

$(".dropbox").click(function(){
    $(this).hide().slideDown();
//    ^---^----------------------- no quotes
});

Example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM