jQuery 是一个JavaScript 库,它有助于简化JavaScript 以及Asynchronous JavaScript + XML (Ajax) 编程,现在使用得越来越多,我这段时间一直在研究jquery的使用,不断的尝试在项目开发中使用,感觉还不错。
下面总结了一些用法:
一、JQUERY处理表单:
<form id="form1">
<input id="tag" name="tag" type="text" >
<input type='checkbox' name='boxB0' value='贫血'>贫血
<input type='checkbox' name='boxB1' value='鼻炎'>鼻炎
<input type='checkbox' name='boxB2' value='白内障'>白内障
<input type='checkbox' name='ddboxB2' value='hhhhhh>hhhhhhhhh
</from>
<script type="text/javascript">
$(document).ready(function(){
/* 获取被选中的 checkbox的值
$("#form1 input[@type=checkbox][@name*=box][@checked]"):
获取form中name包含box的checkbox中被选中的checkbox;
each用来遍历选中的checkbox
*/
$("#form1 input[@type=checkbox][@name*=box][@checked]").each(function(i){
$(this).attr("value") ;//获取checkbox的值
});
//选中 checkbox
$("#form1 input[@type=checkbox][@name*=box]").each(function(i){
if( $(this).attr("value") == "鼻炎"){
$(this).attr("checked",true);
}
});
//修改 tag 文本框 的值
$('#tag').attr("value",“标签”);
});
</script>
<!---------------------------------未完待续---------------------------------->