方便区别jquery对象跟dom对象,首先做好好的编程习惯
一般jquery对象前面加“$“:var $sure = $("#sure");
dom对象直接编写: var sure = document.getElementById("sure").value;
jquery给html标签添加属性
$sub.attr("disabled","disabled");
jquery给html标签移除属性
$sub.removeAttr("disabled")
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link href="/Content/style.css" rel="stylesheet" type="text/css" />
		<title>jQuery测试</title>
		<script type="text/javascript" src="../jquery/jquery-1.3.1.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				var $sure = $("#sure");
				var $sub = $("#sub");
				var sure = document.getElementById("sure").value;
				$sure.click(function(){
					if(!$sure.is(":checked")){
						$sub.attr("disabled","disabled");
					}
					if($sure.is(":checked")){
						$sub.removeAttr("disabled")
					}
				})
			})
		</script>
	</head>
	
	<body>
		<input type="checkbox" id="sure" />同意并接受注册协议
		<input type="button" disabled="disabled" value="提交" id="sub" />
	</body>
</html>
jQuery操作DOM与HTML元素属性
        
                  
                  
                  
                  
                            
                            
本文详细介绍了如何使用jQuery方便地操作DOM对象和HTML元素属性,包括添加、移除属性的方法,以及如何通过jQuery对象的特性进行条件判断和操作。
          
      
          
                
                
                
                
              
                
                
                
                
                
              
                
                
              
            
                  
					350
					
被折叠的  条评论
		 为什么被折叠?
		 
		 
		
    
  
    
  
            


            