.rules-container
andrules-buttons
have got the same count of child elements.- I want to make jQuery code thats get child value of
rules-button.active
and setdisplay:block
to the same child value of "p" element in.rules-container
I wrote jQuery code thats highlight the icons but I don't know how to write the second stage of my function. Is there any way to make is simple via jQuery or css?
$(document).ready(function() {
$('.rules-button').click(function() {
if ($('.rules-button').hasClass('active')) {
$('.rules-button').removeClass('active');
}
$(this).addClass('active');
});
});
.rules-container {
display: grid;
background: #f2f2f2;
text-align: center;
border-radius: 2px;
padding: 20px;
grid-row: 2/3;
align-items: center;
}
.content .rules-container p {
color: #080808;
font: 400 14px 'Open Sans', sans-serif;
}
.content .rules-buttons {
display: grid;
grid-row: 3/4;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr;
align-items: center;
justify-items: center;
}
.rules-buttons .rules-button {
display: grid;
width: 56px;
height: 56px;
background: #1a1a1a;
border-radius: 50%;
align-items: center;
justify-items: center;
transition: 250ms cubic-bezier(.75, 0, .25, 1);
}
.rules-buttons .rules-button.active {
background: #ffff00;
animation: borders-animation 2000ms infinite ease-in-out;
}
.rules-buttons .rules-button img {
display: grid;
width: 40px;
height: 40px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="rules-container">
<p>text 1</p>
<p style="display: none">text 2</p>
<p style="display: none">text 3</p>
</div>
<div class="rules-buttons">
<div class="rules-button active">ee<img src="icon/lock_open.svg" alt=""></div>
<div class="rules-button"><img src="icon/timeline.svg" alt=""></div>
<div class="rules-button"><img src="icon/explore.svg" alt=""></div>
</div>