48
rated 0 times
[
55]
[
7]
/ answers: 1 / hits: 34156
/ 9 Years ago, fri, july 17, 2015, 12:00:00
$(document).ready(function(){
var $pageItem = $(.pagination li)
$pageItem.click(function(){
$pageItem.removeClass(active);
$(this).addClass(active);
});
});
<script src=https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js></script>
<link href=https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css rel=stylesheet/>
<nav>
<ul class=pagination>
<li>
<a href=# aria-label=Previous>
<span aria-hidden=true>«</span>
</a>
</li>
<li><a href=#>1</a></li>
<li><a href=#>2</a></li>
<li><a href=#>3</a></li>
<li><a href=#>4</a></li>
<li><a href=#>5</a></li>
<li>
<a href=# aria-label=Next>
<span aria-hidden=true>»</span>
</a>
</li>
</ul>
</nav>
Now, I am using bootstrap pagination and add some customise feature using jQuery to make page active when I click on it which mean current page.
However, the prev and next button will be also active.
What can I do to only switch page active when click on prev or next button and not to add active to prev and next button.
More From » jquery