开发者

jQuery $(this) childern

开发者 https://www.devze.com 2023-02-14 21:09 出处:网络
How can I select child elements of this: <ul id=\"menu\"> <li> <a href=\"#\">a</a>

How can I select child elements of this:

<ul id="menu">
 <li>
   <a href="#">a</a>
 </li>
 <li>
   <a href="#">b</a>
 </li>
 <li>
   <a href="#">b</a>
 </li>
</ul>

jQuery:

$('#menu ul li').each(function () {
            $(this).hover(function () {
                // HERE I WANT SELECT "a" , $(thi开发者_开发知识库s).a OR SOMETHING LIKE THAT
            });
        });

I want to add animation on all "a" if their "li" is selected.


Use $(this).find('a') or $(this).children('a') or $('a', this)


$('#menu ul li').each(function () {
            $(this).hover(function () {
                $('a', $(this))
            });
        });
0

精彩评论

暂无评论...
验证码 换一张
取 消