js如何判断一个按钮在今年内是否被按下,如果被按下过一次就灰掉?求各路大神帮忙,急!!!
解决方案 »
- 求教页面节点属性改变的监听方法
- 点击按钮移动DIV
- ie9 js判断文件上传大小
- 请问专职Web前端开发需要具备什么样的能力?
- 求JavaScript核心技术和javascript高级编程电子书
- 求教: new ActiveXObject("MSXML2.DOMDocument.3.0") 需要ie的版本多高哇? 我的总是有黄的叹号!
- 急!在线到24点。用 innerHTML 改 select中的选项为什么不行
- 请问,如何实现在打印中途停止打印的功能?(在网页中,技术不限)
- IE中,光标在画面上时,按BACKSPACE时为什么总有响应那?IE在干什么?
- 哪儿有JDK的中文帮助文当下载??
- Highcharts already defined in the page
- JS里的flot插件画柱状图时,怎么做对比
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head><body>
<button id="btn" value="按钮" onclick="fns()">按钮</button>
<script type="text/javascript">
function fns() {
var timer = new Date();
var the_year = timer.getFullYear();alert(the_year);
if(/2013/.test(the_year)) {
document.getElementById('btn').disabled = 'disabled';
}
}
</script>
</body>
</html>
一直关注此贴。。
就看xdjms怎么回复呢。。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head><body>
<button id="btn" value="按钮" onclick="fns()">按钮</button>
<script type="text/javascript">
function setCookie(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=")
if (c_start!=-1)
{
c_start=c_start + c_name.length+1
c_end=document.cookie.indexOf(";",c_start)
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end))
}
}
return ""
}function fns() {
var this_year = getCookie('this_year');
var the_current = (new Date()).getFullYear();
if(this_year == the_current) {
document.getElementById('btn').disabled = 'disabled';
} else {
the_value = (new Date()).getFullYear();
setCookie('this_year',the_value);
}}
window.onload = function() {
var this_year = getCookie('this_year');
var the_current = (new Date()).getFullYear();
if(this_year == the_current) {
document.getElementById('btn').disabled = 'disabled';
} else {
the_value = (new Date()).getFullYear();
setCookie('this_year',the_value);
}}
</script>
</body>
</html>