Tomislav Nikolic
Tomislav Nikolic

Reputation: 171

Getting next class of a div using jquery

Alright so basically I am trying to get the class of next div element that is outside the current element and append to it. I've had various attempts but couldnt actually get any good result. I want to append to only the next class and not all of them

<div class="wrapper">
    <a class="reveal-options">Click me</a>
    <div class="hidden"></div>
</div>  
<div class="wrapper">
    <a class="reveal-options">Click me</a>
    <div class="hidden"></div>
</div>
$(".reveal-options").on("hover",function() {
    $('.reveal-options').closest('.hidden').css({"display":"block"});   
});

This jquery is innacurate for some reason

EDIT: I cant use next since in some cases reveal-options will hold some data such as div or such

Upvotes: 0

Views: 226

Answers (2)

uvishere
uvishere

Reputation: 430

You can try:

$(".reveal-options").on("hover",function() {
    $('.reveal-options').next('.hidden').css({"display":"block"});   
});

Upvotes: -1

danish farhaj
danish farhaj

Reputation: 1354

use this

 $(".reveal-options").on("hover",function() {
    $(this).next('.hidden').css({"display":"block"});   
});

Upvotes: 2

Related Questions