jQuery:但是所有的孩子呢? [英] jQuery: but what about all the children?

查看:153
本文介绍了jQuery:但是所有的孩子呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在某些jQuery函数中使用太多的 .children()
$ b



这是我的HTML:

 < div class =goal-small-container> 
< div class =goal-content>
< div class =goal-row>
< span class =goal-actions>

这里是我的jQuery:

  $('。goal-small-container')。hover(function(){
$(this).children('。goal-content' ('goal-actions')。css({visibility:visible});
},function(){
$(this).children内容)。child('。goal-row')。children('。goal-actions')。css({visibility:hidden});
});

有更好的方法吗?

$

  .find('。goal) -content .goal-row .goal-action')。whatever()

/ p>

  .find('。goal-action')whatever()
pre>

I feel like I have to use way too many .children() in some of my jQuery functions.

Here's my HTML:

<div class="goal-small-container">
  <div class="goal-content">
    <div class="goal-row">
      <span class="goal-actions">

And here's my jQuery:

$('.goal-small-container').hover(function() {
  $(this).children('.goal-content').children('.goal-row').children('.goal-actions').css({visibility: "visible"});
}, function () {
  $(this).children('.goal-content').children('.goal-row').children('.goal-actions').css({visibility: "hidden"});
});

Is there a better way? Tell me for the kids.

解决方案

.find('.goal-content .goal-row .goal-action').whatever()

or more simply:

.find('.goal-action').whatever()

这篇关于jQuery:但是所有的孩子呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆