Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 249287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:24:53+00:00 2026-05-11T21:24:53+00:00

I display a bunch of posts from users on a page. I have the

  • 0

I display a bunch of posts from users on a page. I have the main parent div with the class name ‘posts’ and each post is outputted in a div with class name ‘row’ inside of it. So there’s a whole lot of div.row’s inside the div.posts. Each look like this.

<div class="row clearfix">
    <div class="left-column">
        <img src="..." title="" />
    </div>
    <div class="main-column">
        <div class="row-text">Post Text...</div>
        <div class="row-date">Posted Date...</div>
    </div>
    <div class="actions-column">
        <a href="#">Link</a>
        <a href="#">Link 2</a>
        <a href="#">Link 3 etc.</a>
    </div>
</div>

Via CSS the actions-column is set to display:none by default. When a user mouseover’s a post (div.row) I want to show the actions-column. My initial way of doing it was by setting a mouseover even for each row and that was taking it’s toll on the browser and slowing things down. I did some research and stumbled upon event delegation and decided to give it a try. So far I am able to identify which row is being targeted, however, I cannot figure out how to target it’s child-div with the class ‘actions-column’.

Code so far…

$(window).load(function(){

    $('.posts').mouseover(function(e){
        var $row, $tgt = $(e.target);

        if ($tgt.hasClass("row")) {
            $row = $tgt;
        } else { 
            if ($tgt.parent().parent().hasClass('row'))
                $row = $tgt.parent().parent();

            else if ($tgt.parent().hasClass('row'))
                $row = tgt.parent();    

            else
                return false;       
        }

        //code here to select div.actions-column and show it

    });

    $('.posts').mouseover(function(e){
        var $row, $tgt = $(e.target);

        if ($tgt.hasClass("row")) {
            $row = $tgt;
        } else { 
            if ($tgt.parent().parent().hasClass('row'))
                $row = $tgt.parent().parent();

            else if ($tgt.parent().hasClass('row'))
                $row = tgt.parent();    

            else
                return false;       
        }

        //code here to select div.actions-column and hide it

    });

});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:24:54+00:00Added an answer on May 11, 2026 at 9:24 pm

    You could use live:

    $('div.row').live('mouseover', function() {
        $(this).find('div.actions-column').show();
    }).live('mouseout', function() {
        $(this).find('div.actions-column').hide();
    });
    

    As the documentation notes:

    When you bind a “live” event it will bind to all current and future elements on the page (using event delegation).

    A couple more notes:

    • I see you are using the $(window).load() event. You probably want $(document).ready()
    • You should take advantange of jQuery’s chaining capabilities instead of querying for $('.posts') twice, you can just append the second call at the end (like I did in my example above) – this is much more efficient and the preferred way of doing multiple things to 1 selector in jQuery.
    • The code you are trying to write to find the next div.row up the HTML tree has already been implemented by jQuery’s closest() method.

    You could do something like this with it:

    $('div.posts').hover(function(e) {
        var row = $(e.target).closest('div.row');
        $row.find('div.actions-column').show();
    }, function(e) {
        var row = $(e.target).closest('div.row');
        $row.find('div.actions-column').hide();
    });
    

    But this is not necessary because of the live functionality I showed above.

    • Think about the efficiency of your queries. If you only have a single <div> with a class of posts, consider giving it an id attribute. This is by far the most efficient method of selecting elements in a document, and it makes sense to give it to elements that only occur once.
    • Whenever you are querying for an element by class, it is good practice to include the tag name before the class (unless you expect it to be in many different tags, of course) – so instead of looking for .row, make a habit of looking for div.row instead. It’s just faster.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to display a bunch of images in a page. Images are of
We have a set of applications that basically display a bunch of bitmaps and
I have a bunch of variables I want to display of which some are
We have an HTML page which displays a bunch of pretty bars using divs
I've been making a combined social media feed class which gets posts from Facebook
I have a bunch of texts and images (taken from the content tag of
I have a bunch of Posts. I want that for the index action, the
I have a page that dynamically generates any number of divs.  Inside the div
I have a bunch of Aweber forms with just a name and email field
I want to display a bunch of Objects i have created in a ListBox.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.