JQuery(二)

  还是觉得有必要对最近做过的项目中常见的一些jquery用法做一个总结,也算是加深一点点印象吧。以下内容没有任何逻辑,想到了即写出来而已!

  1.jquery遍历读取table中第一列的数据

1 for(var i=1;i<$("#department").find("tr").length;i++){
2         department += $("#department tr:eq("+i+") td:nth-child(1)").text() + ",";
3     }

  2.jquery循环遍历读取选中的checkbox的数据

1     var strcode= new Array();
2     var strdesc = new Array();
3     $("input#checkbox").each(function(){ 
4         if($(this).attr("checked")){
5             strcode.push($(this).attr("_code"));
6             strdesc.push($(this).attr("_desc"));
7         }
8     });

  3.jquery选中radio

1 if(result.isAllProduct == true){
2     $("input:radio[value='yes']").attr('checked','true');
3 }else{
4     $("input:radio[value='no']").attr('checked','true');
5 }

  4.jquery动态改变html

1 //method one
2 $("#unProducts").append(stradd);
3 
4 //method two
5 $("input#addconditionone").click(function(){
6         $(StrUtil.str1).appendTo('#addconditionone1');  
7 });

  5.jquery操作选择框

1 var scopeid = $("#activityscope").find("option:selected").val();

   6.jquery siblings()用法 :获取匹配集合元素的所有同胞元素

1 //p 元素的所有类名为 "selected" 的所有同胞元素
2 $("p").siblings(".selected").css("background", "yellow");
3 
4 $j('div.detail_menu li').mouseover(function(){
5       var $jthis = $j(this);
6       $jthis.addClass('curr').siblings().removeClass('curr');
7 }

 7.jquery toggle用法

1 $j("#select-hold").toggle(function(){
2             $j(this).html("<b></b>收起").attr("class","close");
3             $j("#select-brand .content_extend div").slice(15).attr("class","");
4         },function(){
5             $j(this).html("<b></b>展开").attr("class","open");
6             $j("#select-brand .content_extend div").slice(15).attr("class","hidden");
7     });

 

 

  

转载于:https://www.cnblogs.com/matrix-skygirl/archive/2012/11/28/2793864.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值