简体   繁体   English

在AJAX分页中添加“活动”类

[英]Add class 'active' in AJAX Pagination

I have a pagination, and my pagination is not using any plugin, I just create it by myself. 我有一个分页,而我的分页没有使用任何插件,而是由我自己创建的。 But, I have a problem, how can I give a class='active' when the button is clicked. 但是,我有一个问题,当单击按钮时如何给class='active' I just using function in my pagination. 我只是在分页中使用功能。 Please help, thank you. 请帮忙,谢谢。

$(document).on('click','your-element-class', function() {
    if ($(this).hasClass('active')) {
        $(this).removeClass('active');
    } else {
        $(this).addClass('active');
    }
});

When the element is clicked, if it already has the active class, it will be removed; 单击该元素时,如果它已经具有active类,则将其删除;否则,将其删除。 otherwise it will be added. 否则它将被添加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM