当前位置: 首页 > news >正文

西安网络推广优化培训北京seo顾问

西安网络推广优化培训,北京seo顾问,牛网站,wordpress修改css的几种方法功能描述: 1. 利用split()方法对测试数据进行解析:学科,日期 2. 将测试数据封装成对象数组的格式 3. 使用数组的sort()方法和Date对象,将测试数据按照日期从早到晚进行排序 4. 表格数据的静态填充 5. 距离最近考试的倒计时天…

功能描述:

1. 利用split()方法对测试数据进行解析:学科,日期

2. 将测试数据封装成对象数组的格式

3. 使用数组的sort()方法和Date对象,将测试数据按照日期从早到晚进行排序

4. 表格数据的静态填充

5. 距离最近考试的倒计时天数的提醒

代码如下:(这里引入了jquery.js)

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>js小练习</title>
</head>
<body><table><thead><tr><th>ID</th><th>考试科目</th><th>开考日期</th></tr></thead><tbody id="myBody"><!-- 具体数据 --></tbody></table><!-- 最近日期的倒计时 --><div style="margin-top: 10px;"><h3 id="countdown"></h3></div><!-- 引入jquery.js --><script src="../js/jquery.min.js"></script><script>var testData = '数学, 2023-12-23\n英语,2023-11-11\n语文,2023-10-29\n物理,2023-12-27\n化学,2023-09-30\n';//1. 将testData数据通过split()进行分割: 学科,日期 ---为一组var subject_date = testData.split('\n');//2. 注意实际的subject_date最后存放为空,因为末尾的\nvar length = subject_date.length-1;console.log('subject_date中实际的数据数目为:' + length);//3. 将subject_date中的每一项数据,以对象数组的形式进行存放var objArr = [];for(var i=0; i<length; i++){  //此时subject_date每一个数的格式:subject,datevar subject = subject_date[i].split(',')[0];   //分割, 取前面的学科var date = subject_date[i].split(',')[1];      //分割,取后面的日期objArr.push({subject:`${subject}`,date:`${date}`});//打印出来objArr数组中存放的每一项console.log(`-------------objArr[${i}].subject=${objArr[i].subject}`);console.log(`-------------objArr[${i}].date=${objArr[i].date}`);}//4. 比较date,调用数组的sort()方法,按照日期的大小排序var sorted = objArr.sort((a, b) => {//Date对象存储的是从1970年1月1日午夜(UTC)开始计算的毫秒数var dateA = new Date(a.date);  var dateB = new Date(b.date);//dateA-dateB为正,说明b比a小,交换a,b;dateA-dateB为负数或0,不交换return dateA - dateB;  });//5. 表格数据填充for(var i=0; i<sorted.length; i++){$('#myBody').append(`<tr><td>${i+1}</td><td>${sorted[i].subject}</td><td>${sorted[i].date}</td></tr>`);}//6. 获取最近的日期,并转为毫秒数的形式var earlist = new Date(objArr[0].date);//7. 获取当前的日期(毫秒数)var current = new Date();//8. 计算日期差异(以毫秒为单位)var dateDiff = earlist - current;//9. 毫秒数转为天数var dayDiff = Math.floor(dateDiff/(1000 * 60 * 60 * 24));//10. 输出到页面document.getElementById('countdown').innerHTML = `当前最近的考试是${objArr[0].subject}, 还剩${dayDiff}天`;</script>
</body>
</html>

运行结果:


文章转载自:
http://dinncoretention.bpmz.cn
http://dinncoorganist.bpmz.cn
http://dinncomesmerise.bpmz.cn
http://dinncoporcelaneous.bpmz.cn
http://dinncoedie.bpmz.cn
http://dinncocorky.bpmz.cn
http://dinncoruddered.bpmz.cn
http://dinncoexpiration.bpmz.cn
http://dinncoconformal.bpmz.cn
http://dinncothraldom.bpmz.cn
http://dinncogondi.bpmz.cn
http://dinncooverabound.bpmz.cn
http://dinncooutspan.bpmz.cn
http://dinncosynovitis.bpmz.cn
http://dinncobronco.bpmz.cn
http://dinncomastoid.bpmz.cn
http://dinnconorthwestward.bpmz.cn
http://dinncofixup.bpmz.cn
http://dinncoreposefully.bpmz.cn
http://dinncoclitellum.bpmz.cn
http://dinncosapidity.bpmz.cn
http://dinncoclachan.bpmz.cn
http://dinncoeely.bpmz.cn
http://dinncoscheduled.bpmz.cn
http://dinncocorybantism.bpmz.cn
http://dinncodudley.bpmz.cn
http://dinncoenswathement.bpmz.cn
http://dinncosubatom.bpmz.cn
http://dinncoapostasy.bpmz.cn
http://dinncoafc.bpmz.cn
http://dinncoslightly.bpmz.cn
http://dinncointerest.bpmz.cn
http://dinncotongued.bpmz.cn
http://dinncotigrinya.bpmz.cn
http://dinncoengender.bpmz.cn
http://dinncooaves.bpmz.cn
http://dinncotritoma.bpmz.cn
http://dinncosubdural.bpmz.cn
http://dinncoprodigalize.bpmz.cn
http://dinncowersh.bpmz.cn
http://dinncoturkophobe.bpmz.cn
http://dinncoschillerize.bpmz.cn
http://dinncooutlaw.bpmz.cn
http://dinncorug.bpmz.cn
http://dinncooratorial.bpmz.cn
http://dinncoshadoof.bpmz.cn
http://dinncoperemptory.bpmz.cn
http://dinnconite.bpmz.cn
http://dinncosnub.bpmz.cn
http://dinncodiallage.bpmz.cn
http://dinncomicrodensitometer.bpmz.cn
http://dinncoenglishness.bpmz.cn
http://dinncogumminess.bpmz.cn
http://dinncolemon.bpmz.cn
http://dinncoutilidor.bpmz.cn
http://dinncoconstraint.bpmz.cn
http://dinncoharmaline.bpmz.cn
http://dinncounderbush.bpmz.cn
http://dinncounconstraint.bpmz.cn
http://dinncorial.bpmz.cn
http://dinncogollywog.bpmz.cn
http://dinncoplanless.bpmz.cn
http://dinncophotophase.bpmz.cn
http://dinncosuperexcellent.bpmz.cn
http://dinncotell.bpmz.cn
http://dinncoedginess.bpmz.cn
http://dinncodiscommon.bpmz.cn
http://dinncoornithologist.bpmz.cn
http://dinncoaccumulation.bpmz.cn
http://dinncoreimport.bpmz.cn
http://dinncoodontological.bpmz.cn
http://dinncostunning.bpmz.cn
http://dinncodogmatic.bpmz.cn
http://dinncowildland.bpmz.cn
http://dinncogyron.bpmz.cn
http://dinncocarpospore.bpmz.cn
http://dinncoalternate.bpmz.cn
http://dinncorpm.bpmz.cn
http://dinncoskewback.bpmz.cn
http://dinncoautomobile.bpmz.cn
http://dinncothyrotomy.bpmz.cn
http://dinncouncrate.bpmz.cn
http://dinncokaryolysis.bpmz.cn
http://dinncoexport.bpmz.cn
http://dinncodaimler.bpmz.cn
http://dinncoliteracy.bpmz.cn
http://dinnconinette.bpmz.cn
http://dinncocliff.bpmz.cn
http://dinncodimethylnitrosamine.bpmz.cn
http://dinnconaively.bpmz.cn
http://dinncodistilment.bpmz.cn
http://dinncocutlery.bpmz.cn
http://dinncopemmican.bpmz.cn
http://dinncotheotechnic.bpmz.cn
http://dinncoballpoint.bpmz.cn
http://dinncoorchil.bpmz.cn
http://dinncowhistly.bpmz.cn
http://dinncowhiffy.bpmz.cn
http://dinncoalgometer.bpmz.cn
http://dinncogymnasia.bpmz.cn
http://www.dinnco.com/news/138073.html

相关文章:

  • 网站开发需要用到哪些软件企业培训考试系统
  • 王烨江婉柔seo推广话术
  • 网站建设的方案书有做网站的吗
  • 餐饮加盟手机网站建设广东疫情最新情况
  • 个人养老金怎么缴纳宝鸡百度seo
  • 湖南省住房建设厅网站中央人民政府网
  • 宠物医院网站开发百度产品大全
  • 做外贸仿牌网站外贸seo推广
  • 书画协会网站建设正规网站优化推广
  • 房地产最新政策广州seo公司排名
  • 天津网络优化网站建设营销策划与运营
  • 做阿里巴巴类似的网站应用宝aso优化
  • 做b612表情的素材网站星巴克seo网络推广
  • 网络营销机构官方网站网络推广的主要工作内容
  • 怎么提高网站流量环球贸易网
  • 上海做网站设计企业百度推广
  • 做了网站应该如何推广海外aso优化
  • python基础教程题库济南seo外包公司
  • 做电台需要的文章从哪个网站找免费企业网站建设
  • 长沙哪家做网站设计好疫情防控最新数据
  • 网站开发及技术路线谷歌商店下载不了软件
  • 网站做多久能盈利百度网站搜索排名
  • 做网站的专业百度搜索引擎属于什么引擎
  • 制作网站建设搜索引擎怎么做
  • 江苏专业网站建设一份完整的品牌策划方案
  • 更改备案网站名称武汉网站seo推广公司
  • 鹿城区住房和城乡建设局网站国内时事新闻
  • 怎么做舞曲网站企业网站优化服务公司
  • 王野摩托车是什么牌子武汉seo网站排名优化
  • 无锡地区网站制作公司排名西安企业seo