jQuery学习备忘
1.标准的ajax提交:
/** * @param {Object} data_ * @param {Object} url_ */ function getParamsSvnPathAndFileName(data_,url_){ var pathAndFileObj = {} $.ajax({ url:url_,dataType:"json",type:"POST",async:false,data:data_, success:function(data){ if(data){ pathAndFileObj = data; } } }); return pathAndFileObj; }
2.批量添加/删除属性:
$(function(){ $("#content").find("span").each(function(){ $(this).attr("title",$(this).text()); $(this).removeAttr("title"); }); });
3.添加自动汉语提示功能
1 $(".sch input.txt").each(function(){ 2 if(this.value=="") 3 { 4 this.value="自动提示"; 5 this.style.color="#ccc"; 6 } 7 this.initValue = this.value; 8 $(this).click(function(){ 9 if((this.value == this.initValue)){ 10 this.value='';this.style.color='#000'; 11 } 12 }).blur(function(){ 13 if(this.value == '' || (this.value == this.initValue)){ 14 this.value=this.initValue; 15 this.style.color='#ccc'; 16 }else{ 17 this.style.color='#000'; 18 }}); 19 });
4.选择查找
1 $(".tabs .tab li:eq(0)").click(function(){ 2 $(".tabs .tab li").removeClass("current"); 3 $(this).addClass("current"); 4 $("#page_content1").hide(); 5 6 $("#page_content").show(); 7 8 9 $("#page_content").find(".easyui-datagrid").datagrid("resize",{width:800,height:470}); 10 11 }); 12 13 14 $("#tabs li:eq(0)").click();
5.动态修改各个属性
1 jQuery("#ifmTab").attr({height:'100%',width:'100%',frameborder:'0',scrolling:'no',allowtransparency:'true',style:''});