我使用JQuery给一段文本加上鼠标移上去字体变大效果。顺利完成。

$(".TreeView1_0").mouseover(function(){                        
                        $(this).addClass("moveInNode");
                    });
                $(".TreeView1_0").mouseout(function(){
                    $(this).removeClass("moveInNode");

                }); 

 

我想在这个页面上加个复选框,选中复选框的时候有这样的效果,去掉复选框失去这种效果。

if($("#chbIsLarger").attr("checked")){    

 //上面的代码

else{

  $("#chbIsLarger").unbind("mouseover"); //这一句怎么不起作用??????

 

 这个页面的所有代码:

<html>
<head>
<style type="text/css">
        .moveInNode
        {
        font-size:x-large;          
        }
        .clearMoveInNode
        {
        font-size:medium;          
        }
    </style>
<script type="text/javascript" src="jquery-1.4.1.js"></script>
<script type="text/javascript">
function clickCheckbox() {           
                isLarger();                
        }        
        function isLarger(){        
            if($("#chbIsLarger").attr("checked")){            
               $(".TreeView1_0").mouseover(function(){                        
                        $(this).addClass("moveInNode");
                    });
                $(".TreeView1_0").mouseout(function(){
                    $(this).removeClass("moveInNode");
                });
             }
             else{  
                $("#chbIsLarger").unbind("mouseover"); 
             }
        }
</script>
</head>
<body>
<input id="chbIsLarger" type="checkbox" onclick ="return clickCheckbox()" />
<br />
<br />
<br />
<div class="TreeView1_0">请把鼠标指针移动到这个段落上。</div>
</body>

</html> 

 

 

posted on 2011-05-11 15:48  youngshop  阅读(1644)  评论(1编辑  收藏  举报