JavaScript转换提取自己做的后面带有选的字符 绿色的
不做的红色的不选的字样
1.查找设备历史位置信息会保留多久?
14天 (选) 绿色
一个月 (不选) 红色
半年 (不选) 红色
两年 (不选) 红色
JavaScript编写抓包成功选是绿色正确不选红色错误效果
原抓包代码
[https://wwx.lanzoui.com/iSPAQr5pycd ](url)
代码转换 目前后面没有 选或者不选
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>答案</title>
</head>
<body>
<textarea name="text" style="width:100%;height:100px;" id="responsedate"></textarea>
<br/>
<button style="width:100%;height:100px;float:right" onclick="getAnswer()"/>答案</button>
<p id="answer"></p>
<script>
function getAnswer(){
var responseDate=document.getElementById("responsedate").value;
var responseDate1=eval('(' + responseDate + ')');
document.getElementById("answer").innerHTML=responseDate1;
let k=0;
for(let j in (responseDate1.data.tAnswerList)){
k=k+1;
document.write("<p>"+k+"."+(responseDate1.data.tAnswerList[j].tSubjectContent)+"</p></br>");
for(let i in (responseDate1.data.tAnswerList[j].tOptionList)){
if((responseDate1.data.tAnswerList[j].tOptionList[i].tSelect)==1){
document.write("<p style='color:green;'>"+(responseDate1.data.tAnswerList[j].tOptionList[i].tOptionContent)+"</p></br>");
}
if((responseDate1.data.tAnswerList[j].tOptionList[i].tSelect)!=1){
document.write("<p style='color:red;'>"+(responseDate1.data.tAnswerList[j].tOptionList[i].tOptionContent)+"</p></br>");
}
}
}
}
</script>
</body>
</html>
如14天 (选)一个月 (不选)半年 (不选)两年 (不选)
JavaScript编写抓包成功选是绿色正确 不选红色错误效果
就是改下这两行document.write("<p style='color:green;'>"+(responseDate1.data.tAnswerList[j].tOptionList[i].tOptionContent)+"(选)</p></br>");
document.write("<p style='color:red;'>"+(responseDate1.data.tAnswerList[j].tOptionList[i].tOptionContent)+"(不选)</p></br>");
在</p>
前面加(选)和(不选)就好了啊
你题目的解答代码如下:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)
for(let i in (responseDate1.data.tAnswerList[j].tOptionList)){
if((responseDate1.data.tAnswerList[j].tOptionList[i].tSelect)==1){
document.write("<p style='color:green;'>"+(responseDate1.data.tAnswerList[j].tOptionList[i].tOptionContent)+"(选)</p></br>");
}
if((responseDate1.data.tAnswerList[j].tOptionList[i].tSelect)!=1){
document.write("<p style='color:red;'>"+(responseDate1.data.tAnswerList[j].tOptionList[i].tOptionContent)+"(不选)</p></br>");
}
}