菜鸟的jquery学习笔记,jquery添加删除html标签属性:2011-12-19

方便区别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>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值