jquery - 点击事件触发和页面加载后如何运行代码
问题描述
我正在开发一个通过 jquery 触发点击事件的 Web 应用程序。我在变量中还有一个链接 ID,例如“unit30”。所以当点击事件被触发时,新页面被加载。所以我必须在页面上找到该 id 并将类“活动”添加到它。我现在所做的是这个
jQuery(document).on('click','.course_lesson a',function(e){
e.preventDefault();
var href = $(this).attr('href');
var link = href.split("?")[1];
var unit = link.split("=")[1]; // this gives me id unit30
jQuery("input.course_button").trigger("click"); //click event is triggered and new page is loaded. now I have to find unit30 id on this page and add class "active" to it.
});
解决方案
推荐阅读
- ios - SwiftUI Preview 因 stackoverflow 崩溃
- angular - 角度路由参数
- javascript - 一页上的两个按钮下的两个不同的js
- google-cloud-platform - GCP:我们可以在扳手中修改现有表的主键吗
- c# - 插值字符串上的 Ef Core vs Linq
- c# - 创建 lambda 表达式以查询数据
- javascript - Morgan 没有记录其余的 api 调用
- neo4j - 了解 Neo4j 的运算符
- java - 如何使用 JavaScript 在 selenium 中注入日期选择器的值?
- machine-learning - h2o automl 是在哪个框架上构建的?