How can I make the active class in my pagination appear in red? Here's the code snippet I have:
In my script.js file:
$(".pagination").append("<li class='page-item' id='previous-page'><a class='page-link' href='javascript:void(0)' aria-label=Previous><span aria-hidden=true>»</span></a></li>");
$(".pagination").append("<li class='current-page active'><a class='page-link' href='javascript:void(0)'>" + 1 + "</a></li>");
for (var i = 2; i <= totalPages; i++) {
$(".pagination").append("<li class='current-page'><a class='page-link' href='javascript:void(0)'>" + i + "</a></li>"); // Insert page number into pagination tabs
}
$(".pagination").append("<li class='page-item' id='next-page'><a class='page-link' href='javascript:void(0)' aria-label=Next><span aria-hidden=true>»</span></a></li>");
$(".pagination li.current-page").on("click", function() {
//checks if the user is at the current page
if($(this).hasClass("active")){
return false;
}else{
//removes active class and adds it from what the user is clicking
var currentPage = $(this).index();
$(".pagination li").removeClass("active");
$(this).addClass("active");
$("#page .content").hide();
}
And in my style.css file:
.pagination a:active{
background-color: red;
color:red;
}
The issue I'm facing is that the <a>
tag only turns red when clicked, but reverts back to blue once the mouse is released. How can I make sure it stays red while active?