从奥鹏一个答案提取页面 看jquery知识点
2024-08-28 20:49:50
http://oldlearn.open.com.cn/OEMSExercise/HomeworkReview.aspx?HomeworkId=9c034488-0a3d-4b9d-a6cc-e42200459094&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&SectionIndex=1
想要提取页面上 选定答案的 并且打印到控制台
var answer=''; $('.TestItemBody').each(function(i){var txt=$(this).children(":last").text().match(/([A-Z]+)/g)[0]; answer+=txt; if((i+1)%5==0)answer+=' '; if($(this).parent().attr('id')=='divSection2')answer+=' '; });console.log(answer); var answer=''; $('.TestItemBody').each(function(i){ $(this).children().find("input").each(function(j){ if($(this).attr("checked"))console.log(i+" "+j+" "+$(this).attr("checked",true)[0].nextSibling.nodeValue);}) }) var answer=''; $('.TestItemBody').each(function(i){ $(this).children().find("input").each(function(j){ if($(this).attr("checked")){ var ans= $(this).attr("checked",true)[0].nextSibling.nodeValue.match(/([A-Z]+)/g)[0]; answer+=ans; } }); if((i+1)%5==0)answer+=' '; if($(".myCourseNavOver").text().lastIndexOf("多选题")!=-1)answer+=' '; }); console.log(answer); var answer = ''; $('.TestItemBody').each(function(i) { $(this).children().find("input").each(function(j) { if ($(this).attr("checked")) { var ans = $(this).attr("checked", true)[0].nextSibling.nodeValue.match(/([A-Z]+)/g)[0]; answer += ans; } }); if ((i + 1) % 5 == 0) answer += ' '; if ($(".myCourseNavOver").text().lastIndexOf("多选题") != -1) answer += ' '; }); console.log(answer); // jquery 方式获取radio的 文本值 $(this).attr("checked", true)[0].nextSibling.nodeValue; //只取 字母部分 $(this).attr("checked", true)[0].nextSibling.nodeValue.match(/([A-Z]+)/g)[0]; var answer=''; $('.TestItemBody').each(function(i){ $(this).children().find("input").each(function(j){ if($(this).attr("checked")){ var ans= $(this).attr("checked",true)[0].nextSibling.nodeValue.match(/([A-Z]+)/g)[0]; answer+=ans; } }); if((i+1)%5==0)answer+=' '; if($(".myCourseNavOver").text().lastIndexOf("多选题")!=-1)answer+=' '; }); console.log(answer); 多选题: ABC ABCD AB ABC CD ABC AD AB C BCD var answer=''; $('.TestItemBody').each(function(i){ $(this).children().find("input").each(function(j){ if($(this).attr("checked")){ var ans= $(this).attr("checked",true)[0].nextSibling.nodeValue.match(/([A-Z]+)/g)[0]; answer+=ans; } }); if((i+1)%5==0)answer+=' '; if($(".myCourseNavOver").text().lastIndexOf("多选题")!=-1)answer+=' '; }); console.log(answer); 单选题: BBAAA BAABA
最新文章
- Basic Tutorials of Redis(2) - String
- [转]使用EasyRsa3为OpenVPN生成密码
- [ORM] Entity Framework(2) CodeFirst进阶
- 三种另外的循环 while{} 和do{}while{}还有switch case
- novnc ignoring socket not reay
- Object.defineProperty 规则
- Android多线程断点续传下载
- AnsiString 在 Delphi 中虽然不可用,但是,在 C++ 中可以用
- 调试时a标签禁止跳转方法
- nginx+ftp搭建图片服务器(Windows Server服务器环境下)
- jmeter通过org.sqlite.JDBC驱动连接db数据库
- C语言_简单的阶乘函数
- 携程Android App的插件化和动态加载框架
- Java 锁优化
- P1880 [NOI1995]石子合并(区间DP)
- 《Head First 设计模式》例子的C++实现(5 单例模式)
- 【基本知识】Flume基本环境搭建以及原理
- C#动态显示时间
- HDU2255(KB10-K 二分图最大权匹配)
- Android开发 sharesdk分享微信/朋友圈的时候只显示文字,不显示链接
热门文章
- Mindjet MindManager 2012 从模板创建出现“Runtime Error pure virtual function call” 解决方法
- 【elasticsearch】(1)centos7 使用yum安装elasticsearch 2.X
- iphone5手机端内容超出iphone6没问题且超出内容为http://.....网址
- BOM 之 location
- [CSS]float&;clear浮动
- git的使用方法总结
- RHEL 7特性说明(六):集群
- 学习Swift--枚举的初步认识 --个人备忘 大神勿喷
- Python学习笔记(一)Python安装及环境变量的配置
- SQL server 连接查询