js如何判断一个按钮在今年内是否被按下,如果被按下过一次就灰掉?求各路大神帮忙,急!!!

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <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>
      

  2.   


    一直关注此贴。。
    就看xdjms怎么回复呢。。
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <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>