zoukankan      html  css  js  c++  java
  • 从奥鹏一个答案提取页面 看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 
    
  • 相关阅读:
    hdu 1896 stones
    各种类型的取值范围
    RSS/PSS/VSZ
    kasan BUG log
    ARM机器码分析
    Linux进程状态
    谢宝友: 深入理解RCU之七:分级RCU实现
    rcu_preempt detected stalls on CPUs/tasks
    Linux 内核 hlist
    linux cmd
  • 原文地址:https://www.cnblogs.com/xmanblue/p/5598174.html
Copyright © 2011-2022 走看看