jquery 问答知识整理 |
本文标签:jquery,问答 获取ID : $(this).attr("id"); :not用法 1. 列表用法 复制代码 代码如下: var notList = []; notList.push("#<%=txtSuggest.ClientID %>"); var textElements = $("input[type=text]:not(" + notList + ")"); var firstFocusItem = null; //遍历Type=Text的元素 textElements.each(function(i) { //TODO }); 2.排它用法 复制代码 代码如下: $("table[id^=tb]:not([id=tbBasicInfo])").each(function() { alert($(this).attr("id")); }); 如果不加[]的话, $("table[id^=tb]:not(tbBasicInfo)"),这样是不行的 这时not是基于前者id^=tb的tb进行:not操作的 恢复BackGround-Color为原始的颜色 background-color:transparent 去掉Href的下划线,已访问过的样式 a, a:visited{ text-decoration: none;} 去掉Li的点样式 li{margin:0; padding:0; list-sytle:none} 获取当前对象的Style中的某种样式 $("#divDept").css("display") CSS BackGround Url 显示不出来 因为IE浏览器和FF对于处理路径有一些差异,在IE下修改boxy.css代码如下 。 复制代码 代码如下: .boxy-wrapper .top-left { background: url(images/boxy-nw.png); } .boxy-wrapper .top-right { background: url(images/boxy-ne.png); } .boxy-wrapper .bottom-right { background: url(images/boxy-se.png); } .boxy-wrapper .bottom-left { background: url(images/boxy-sw.png); } /* IE6+7 hacks for the border. IE7 should support this natively but fails in conjuction with modal blackout bg. */ /* NB: these must be absolute paths or URLs to your images */ .boxy-wrapper .top-left { #background: none; #filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/boxy-nw.png); } .boxy-wrapper .top-right { #background: none; #filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/boxy-ne.png); } .boxy-wrapper .bottom-right { #background: none; #filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/boxy-se.png); } .boxy-wrapper .bottom-left { #background: none; #filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/boxy-sw.png); } 这样就能在IE下显示正常了 。 获取Table对象 $("table[id=tableID]") 或者 $("#tableID")CountDown用法 复制代码 代码如下: $.getJSON( loginServiceUrl,{ method: "Logout"}, function(result) { if (result.Url != null) { $("#transfer").countdown({ until: "+5s", expiryUrl: result.Url, onTick: function(periods){ $(this).text(periods[6]); } }); } }); Google Chrome中text()取值有问题,改为val() Google Chrome 中窗口最大化的问题 以下js代码在FF,IE中没问题 复制代码 代码如下: if (window.screen) { var myw = screen.availWidth; var myh = screen.availHeight; window.resizeTo(400, 400); window.moveTo(0, 0); }
![]() 解决方案:
first of all sorry about my english, its not my native lengauge... i have a xml file that im reading with the sample code above...but when i try to read it from a service web page (http://www.google.com/ig/api?weather=Buenos%20A...),it doesnt show anything... and if i write the same content of this page in a xml file in my pc, it works perfectly... i dont know what am i doing wrong i let u the code that im using maybe u could help me function clima(){ $.ajax({ type: "GET", url: http://www.google.com/ig/api?weather=Buenos%20Aires, dataType: "xml", success: function(data){ var $weather = $(data).find(current_conditions) console.log($weather); } }); } function clima() { $.ajax({ type: "GET", dataType: "xml", url: http://www.google.com/ig/api?weather=Buenos%20Aires, success: function(xml) { var weather = $(xml).find("current_conditions").find("temp_c").attr("data"); alert("Prognostico para hoy: " + weather + " grados"); } }); }
有关于$.ajaxSetup和$.get的问题
|