获取id : $(this).attr(id);
:not用法
1. 列表用法
复制代码 代码如下:
var notlist = [];
notlist.push(#);
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);
}
在chrome中resizeto,resize都是没有效果的。 issue 2091:window.resizeto() doesn't have any effect
by design we don't support resize/move for tabs, only constrained windows. http://www.cnblogs.com/lonz/articles/381022.html
javascript resizeto bug http://code.google.com/p/chromium/issues/detail?id=11523
在google chrome/safari 中textbox默认是可以自由拉长的,为何控制不让其自由拉长。
解决方案:
css to disable resizingtextarea {resize: none;}name=foo>textarea[name=foo] {resize: none;}html is )#foo {resize: none;}
js压缩工具 http://www.brainjar.com/js/crunch/demo.html
缺点:
会把正则表达式中类似*/去除
sample:
value = s.replace(/^0*/, '');
after compress:
value = s.replace(/^0, '');
parseint() 和 number() 兩個函數有什么不同? http://hi.baidu.com/iloverobot/blog/item/bd3ed651ffd362868c5430bf.html
json 问题 http://blog.csdn.net/chinaontology/archive/2007/12/30/2004871.aspx
css置底的提示框
大文件上传 进度条显示 (仿csdn资源上传效果) http://www.cnblogs.com/zengxiangzhan/archive/2010/01/14/1647866.html
可编辑的input http://acme.com/javascript/
jquery设置html头信息 http://home.phpchina.com/space.php?uid=155537&do=blog&id=182698
jquery与prototype(ajaxpro)冲突的解决方法 http://www.cnblogs.com/sxlfybb/archive/2009/06/04/1495995.html
利用jquery + handler(ashx) + linq 實現 autocomplete http://www.dotblogs.com.tw/puma/archive/2009/03/10/7426.aspx
jquery ajax 中文乱码 http://phpxiaoxin.javaeye.com/blog/350544
ajax中文乱码原因分析及解决方案 http://hi.baidu.com/sihillver/blog/item/4d6f32f592920325bc3109d7.html
打造基于jquery的高性能treeview http://kb.cnblogs.com/page/50337/
http://kb.cnblogs.com/page/53517/
利用jquery实现更简单的ajax跨域请求 http://kb.cnblogs.com/page/53433/
jquery.ajax 读取xml first of all sorry about my english, it's not my native lengauge...i have a xml file that i'm 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 doesn't 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 wrongi let u the code that i'm using maybe u could help mefunction 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); } });}
fullsize:一个新的img标签属性(附带jquery实现) http://css9.net/img-fullsize/
http://css9.net/wp-content/uploads/2009/04/fullsize/example.html
有关于$.ajaxsetup和$.get的问题
在common.js中使用
$.ajaxsetup({ url: ….., type: post, cache: true, datatype: json }); $.ajax({ data: { citycode: citycode, flag: flag }, success: function(arealist) { …} });
在pagea页面引入common.js
然后在脚本段中使用 $.get(url);
此处url调用的是一个aspx页面,显示结果为无数据加载!(正常情况:有数据加载。)
然后经过使用ie8的开发人员工具,进行trace error.最终发现原因错误信息(如下)
invalid json: