0

I have an array of badges...

[<div class=​"badge">​</div>​, <div class=​"badge">​</div>​, <div class=​"badge">​​</div>​]

and an array of arrows...

[<div class=​"arrow">​</div>​, <div class=​"arrow">​</div>​, <div class=​"arrow">​</div>​]

I'm trying to get the arrows to display when I hover over the badge so I have something like

$('.badge').hover(function() {
    $('.arrow').show();
}, function() {
    $('.arrow').hide();
});

I'm trying to isolate each individual badge and arrow to hover independently, but I can't seem to isolate it by $('.badge').first() or $('.arrow')[0]

This is the desired result at this website, but I want to do so without having to use so many specific classes like badge1, badge2, badge3, and arrow1, arrow2, arrow3.

HTML

<div class="badge badge1 margin_right">  
    <div class="arrow arrow1 right" style="display: none;"></div>
    <img src="images/logo-bc.png" alt="basecamp"/>
    <h3><a href="#">Basecamp</a><span>®</span></h3>
    <h4>Manage Projects</h4>
    <p>Used by millions for project management.</p>
</div>

2 Answers 2

1

In your case the arrow is an descendant of the badge element, so what you need is to change the display of the arrow inside the badge when you hover a badge.

So

$('.badge').hover(function () {
    $(this).find('.arrow').show();
}, function () {
    $(this).find('.arrow').hide();
});
Sign up to request clarification or add additional context in comments.

Comments

0

This might help you-

$.each([arr1, arr2], function() {
$.each(this, function(i, v) {
    // do something
});
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.