jQuery_toggle

<!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>
    <title></title>
    <script src="jQueryNote/jquery-1.8.2.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {

            //            $('#btn').click(function () {

            //                $('body').toggle(function () {
            //                    $('body').toggleClass('light');
            //                },
            //                 function () {
            //                     $('body').toggleClass('dark');
            //                 });

            //            });
            $('#btn').click(function () {
                $('body').css('backgroundColor','red');
            });

        })
    </script>
    <style type="text/css">
        .light
        {
            background-color: yellow;
        }
        .dark
        {
              background-color: black;
            }
    </style>
</head>
<body>
    <input type="button" name="name" value="灯" id="btn" />

</body>
</html>

posted @ 2013-07-28 23:38  nqsan  阅读(200)  评论(0编辑  收藏  举报