• 从奥鹏一个答案提取页面 看jquery知识点


     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 
    
  • 相关阅读:
    Windows phone 应用开发系列教程(更新中)
    ios实例开发精品文章推荐(8.14)
    Android开发环境——调试器 DDMS相关内容汇总
    docker 发布应用时添加 git revision
    docker环境下数据库的备份(postgresql, mysql)
    golang web 方案
    golang 1.12 自动补全
    区块链简介
    天空的另一半
    Ecto中的changeset,schema,struct,map
  • 原文地址:https://www.cnblogs.com/xmanblue/p/5598174.html
Copyright © 2020-2023  润新知