Home > Web Front-end > HTML Tutorial > 签到问题_html/css_WEB-ITnose

签到问题_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:04:10
Original
1087 people have browsed it

签到领20积分


<script> <br /> <br /> function is_leap(year) { <br /> return (year%100==0?res=(year%400==0?1:0):res=(year%4==0?1:0)); <br /> } //是否为闰年 <br /> <br /> var nstr=new Date(); //当前Date资讯 <br /> var ynow=nstr.getFullYear(); //年份 <br /> var mnow=nstr.getMonth(); //月份 <br /> var dnow=nstr.getDate(); //今日日期 <br /> var n1str=new Date(ynow,mnow,1); //当月第一天Date资讯 <br /> var firstday=n1str.getDay(); //当月第一天星期几 <br /> <br /> var m_days=new Array(31,28+is_leap(ynow),31,30,31,30,31,31,30,31,30,31); //各月份的总天数 <br /> <br /> var tr_str=Math.ceil((m_days[mnow] + firstday)/7); //表格所需要行数 <br /> <br /> //打印表格第一行(有星期标志) <br /> document.write ("<table align='center' cellspacing='0'><tr><td align='center'>日<td align='center'>一<td align='center'>二<td align='center'>三<td align='center'>四<td align='center'>五<td align='center'>六"); <br /> for(i=0;i<tr_str;i++) { //表格的行 <br /> document.write("<tr>"); <br /> for(k=0;k<7;k++) { //表格每行的单元格 <br /> idx=i*7+k; //单元格自然序列号 <br /> date_str=idx-firstday+1; //计算日期 <br /> (date_str<=0 || date_str>m_days[mnow]) ? date_str=" " : date_str=idx-firstday+1; //过滤无效日期(小于等于零的、大于月总天数的) <br /> //打印日期:今天底色为红 <br /> date_str==dnow ? document.write ("<td align='center'>" + date_str + "") : document.write ("<td align='center'>" + date_str + ""); <br /> } <br /> <br /> document.write(""); //表格的行结束 <br /> } <br /> <br /> document.write(""); //表格结束 <br /> </script>


下面的js是显示日历的,怎么实现效果,就是点击a标签签到后,今天的日期有红色背景
style="background-color:red;border-radius:50%;color:white"


回复讨论(解决方案)

签到领20积分


<script> <br /> <br /> function is_leap(year) { <br /> return (year%100==0?res=(year%400==0?1:0):res=(year%4==0?1:0)); <br /> } //是否为闰年 <br /> <br /> var nstr=new Date(); //当前Date资讯 <br /> var ynow=nstr.getFullYear(); //年份 <br /> var mnow=nstr.getMonth(); //月份 <br /> var dnow=nstr.getDate(); //今日日期 <br /> var n1str=new Date(ynow,mnow,1); //当月第一天Date资讯 <br /> var firstday=n1str.getDay(); //当月第一天星期几 <br /> <br /> var m_days=new Array(31,28+is_leap(ynow),31,30,31,30,31,31,30,31,30,31); //各月份的总天数 <br /> <br /> var tr_str=Math.ceil((m_days[mnow] + firstday)/7); //表格所需要行数 <br /> <br /> //打印表格第一行(有星期标志) <br /> document.write ("<table align='center' cellspacing='0'><tr><td align='center'>日<td align='center'>一<td align='center'>二<td align='center'>三<td align='center'>四<td align='center'>五<td align='center'>六"); <br /> for(i=0;i<tr_str;i++) { //表格的行 <br /> document.write("<tr>"); <br /> for(k=0;k<7;k++) { //表格每行的单元格 <br /> idx=i*7+k; //单元格自然序列号 <br /> date_str=idx-firstday+1; //计算日期 <br /> (date_str<=0 || date_str>m_days[mnow]) ? date_str=" " : date_str=idx-firstday+1; //过滤无效日期(小于等于零的、大于月总天数的) <br /> //打印日期:今天底色为红 <br /> date_str==dnow ? document.write ("<td id='now' align='center'>" + date_str + "") : document.write ("<td align='center'>" + date_str + ""); <br /> } <br /> <br /> document.write(""); //表格的行结束 <br /> } <br /> <br /> document.write(""); //表格结束 <br /> <br /> <br /> <br /> function activechange(){ <br /> document.getElementById('now').className='now' <br /> } <br /> </script>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template