javascript - How can I make <li> tag actived? in jQuery -


i have pagination this

this javascript code webpage

var paginglist = $('<ul>', {class: 'pagination list-unstyled list-inline'});                                                                            $('.page_container').append($('<div>', {class:"text-center"}).append(paginglist));                                                                              if (startpage > 10) {                                                                                                                                            var prev_page = $('<li>').append($('<a>', {href: '/bjcam/' + boardname + '/' + (startpage - 1)}).text('prev'));                                                paginglist.append(prev_page);                                                                                                                                }                                                                                                                                                              (var = startpage; <= endpage; i++) {                                                                                                                     if (i > maxpage) break;                                                                                                                                        var current_page = $('<li>').append($('<a>', {href: '/bjcam/' + boardname + '/' + i}).text(i));                                                                paginglist.append(current_page);                                                                                                                             }                                                                                                                                                              if (maxpage > endpage) {                                                                                                                                         var next_page = $('<li>').append($('<a>', {href: '/bjcam/' + boardname + '/' + (startpage + 10)}).text('next'));                                               paginglist.append(next_page);                                                                                                                                }                                                                                                                                                      

i want make <li> actived when paginations clicked now, below code i'm trying do

$('.pagination li').click(function() {                                                                                                                           $('.pagination li').addclass("active")                                                                                                                       }) 

how can make <li> tag actived when clicked?

$('.pagination li').click(function(e) {     $('.navbar li.active').removeclass('active');     var $this = $(this);     if (!$this.hasclass('active')) {         $this.addclass('active');     } }); 

try this...


Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -