Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reduce the amount of children I use in my jQuery functions?

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? How can I reduce the amount of children I use in my jQuery functions?

like image 537
Josh Smith Avatar asked Oct 04 '10 01:10

Josh Smith


1 Answers

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

or more simply:

.find('.goal-action').whatever()
like image 129
meder omuraliev Avatar answered Oct 13 '22 05:10

meder omuraliev