dongzhang1839 2013-06-13 02:00
浏览 22

如何从链接中删除一个类...只在一个页面上?

I'm trying to create a 404.php page and would like to remove the "current state" class from a link, only on that page.

As of right now this is what I've got...

jQuery( function() {

    if ( TEMPLATE_URI + '/404.php'.hasClass( '.current_page_parent' ) ) {

            jQuery( '.menu' ).removeClass( '.current_page_parent' );
    }

});

which does not seem to be working.

I am a beginner in the subject of jQuery so any help would be appreciated!

  • 写回答

3条回答 默认 最新

  • dongpiaozhao6836 2013-06-13 02:07
    关注

    I think this should work :

    if(window.location.href.indexOf('404.php') != -1){
         jQuery('.current_page_parent').removeClass('current_page_parent')
    }
    

    Also, when using removeClass, you don't need to put the dot.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?