Memo: Jquery 常忘语句

1.页面加载执行语句

		    jQuery(document).ready(function ($) {
		     //   $(".tabs").tabs();
 
		    });

2.  ajax  交互并渲染页面的combobox 控件

	       function foo(product_id)
	       {     
	   	        $.ajax({     
	   	        type: "GET",     
	   	        url: "getFoo?productname="+product_id,     
	   	        dataType:   "json",   
                        //async:false,//取消异步请求
	   	        success: function(data,textStatus){     
	   	            // display    
	   	          
	   	     
	               var bnSelect = document.getElementById("mycombobox");
	                   for ( var i=bnSelect.options.length-1; i>-1; i-- )
	                   {     
	                   	bnSelect[i] = null;
	                   }     
	               if(data.length > 0) {
	                         $("#mycombobox").show(); 
			   	        for(i=0;i<data.length;i++)
			   	        {     
			   	                bnSelect.options[i] = new Option();     
			   	                bnSelect.options[i].text = data[i].label;     
			   		            bnSelect.options[i].value = data[i].value;     
			            }   
			   	     bnSelect.options[0].selected="selected";// default select the first one
	   	        	}
	   	  
	           }// end of success....func    
	   	    })   //end of ajax
	      }//end of func

3.  隐藏/显示 div 或 tr td 控件

                               $('#myid').css("display", "none");//hide this.

                              $('#myid').css("display", "");//show this.    

4. set requried 域, remove required

	    	  var all_row=$("tr[name^='tr_']")
	    	  all_row.prop('required',true);
                  all_locale_row.removeAttr('required'); // remove required 
遇到一个异常报“An invalid form control with name=xxx is not focusable” ,通常是因为设置了required 域后的控件被隐藏的缘故,不过在实际中,遇到该异常提示的name与实际出问题的控件名字不一致的情况……不晓得为什么
5.  set  text

对<p>:

	    	var msg = "Must select target locales !";
	   	$('#my_p').text(msg);

6. get value for  multi-select

             var targeted = $('#selectTarget').val();
              if (targeted == null)
              {
                 // do something
              }
              for(var i =0;i<targeted.length;i++)
            {
                  var locale_r=$('#tr_'+targeted[i]);
                 locale_r.css("display", "");//show this.
                 locale_r.prop('required',true);
            }


To be continued....


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值