I have recently started learning about jquery. In my code, I have two p
tags with classes .angle_up
and .angle_down
respectively.
The angle_up
class initially has the active
class assigned to it. When a user clicks on .angle_down
, I want to remove the .active
class from angle_up
and apply it to .angle_down
.
I want to display the element with the class ele
with an animated effect when the active
class is present. Essentially, I want to achieve a toggle effect. Any ideas on how I can accomplish this? Thank you in advance.
$(document).on("click", ".angle_up", function () {
$(this).removeClass("active");
var angledwn = $('.angle_down');
angledwn.addClass("active");
var ele = $('.ele');
ele.toggle('5000');
});
.angle_up, .angle_down{
color: #0096C9;
display: none;
}
.angle_up.active, .angle_down.active{
color: #0096C9;
cursor: pointer;
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="angle up active">First</p>
<p class="angle_down"> Second</p>
<p class="ele">To hide or display</p>