jquery 问答知识整理


Posted in Javascript onFebruary 11, 2010

获取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); 
}

  • 在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默认是可以自由拉长的,为何控制不让其自由拉长。

jquery 问答知识整理

解决方案:

CSS to disable resizing

textarea {
resize: none;
}
<textarea name="foo">

textarea[name=foo] {
resize: none;
}

HTML is <textarea id="foo">)

#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() ???函?涤惺裁床煌??/STRONG>

http://hi.baidu.com/iloverobot/blog/item/bd3ed651ffd362868c5430bf.html

  • JSON 问题

http://blog.csdn.net/chinaontology/archive/2007/12/30/2004871.aspx

  • CSS置底的提示框

jquery 问答知识整理

jquery 问答知识整理

  • 大文件上传 进度条显示 (仿csdn资源上传效果)

http://www.cnblogs.com/zengxiangzhan/archive/2010/01/14/1647866.html

  • 可编辑的Input

http://acme.com/javascript/

jquery 问答知识整理

  • 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 wrong
i let u the code that i'm 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");
  }
 });
}

 

  • FullSize:一个新的IMG标签属性(附带JQuery实现)

http://css9.net/img-fullsize/

jquery 问答知识整理

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: <form name="form1" method="post" action="ajax_select

那么如何解决呢?

原因:

        肯定是请求数据类型有问题?

解决方案:

        1.在Page A 页面脚本段 $.get(url,“html”); 

          因为$.get中的Data是可选项,现在确定原因之后,我们就来预定义好DataType

       结果:OK

分析源由:

     是因为$.ajaxSetup是用全局设定的,所以全局已经设定了DataType:JSON了。

     那Page A 页面的$.get()肯定受及影响。

jquery 问答知识整理

最终解决方案:

    改Common.js,去掉ajaxSetup全局设定

       $.ajax({ url: "…..", type: "POST", cache: true, dataType: "json",data: { cityCode: cityCode, flag: flag }, success: function(areaList) { …} });

    结果:OK

     jquery 问答知识整理

Javascript 相关文章推荐
分享27款非常棒的jQuery 表单插件
Mar 28 Javascript
工作需要写的一个js拖拽组件
Jul 28 Javascript
js 事件截取enter按键页面提交事件示例代码
Mar 04 Javascript
javascript浏览器窗口之间传递数据的方法
Jan 20 Javascript
js图片切换具体实现代码
Oct 13 Javascript
tablesorter.js表格排序使用方法(支持中文排序)
Feb 10 Javascript
vue使用axios实现文件上传进度的实时更新详解
Dec 20 Javascript
Vue组件创建和传值的方法
Aug 17 Javascript
自定义Vue中的v-module双向绑定的实现
Apr 17 Javascript
layui异步加载table表中某一列数据的例子
Sep 16 Javascript
JavaScript面试中常考的字符串操作方法大全(包含ES6)
May 10 Javascript
详解微信小程序「渲染层网络层错误」的解决方法
Jan 06 Javascript
改善你的jQuery的25个步骤 千倍级效率提升
Feb 11 #Javascript
jQuery 改变CSS样式基础代码
Feb 11 #Javascript
jQuery 添加/移除CSS类实现代码
Feb 11 #Javascript
JavaScript Event学习补遗 addEventSimple
Feb 11 #Javascript
JavaScript 输入框内容格式验证代码
Feb 11 #Javascript
Extjs学习过程中新手容易碰到的低级错误积累
Feb 11 #Javascript
我遇到的参数传递中 双引号单引号嵌套问题
Feb 11 #Javascript
You might like
基于PHP生成静态页的实现方法
2013/05/10 PHP
php与java通过socket通信的实现代码
2013/10/21 PHP
服务器迁移php版本不同可能诱发的问题
2015/12/22 PHP
onpropertypchange
2006/07/01 Javascript
Ajax一统天下之Dojo整合篇
2007/03/24 Javascript
WordPress JQuery处理沙发头像
2009/06/22 Javascript
JavaScript面向对象之静态与非静态类
2010/02/03 Javascript
利用jQuery 实现GridView异步排序、分页的代码
2010/02/06 Javascript
jQuery获取Select选择的Text和Value(详细汇总)
2013/01/25 Javascript
js调用后台、后台调用前台等方法总结
2014/04/17 Javascript
浅谈Jquery为元素绑定事件
2015/04/27 Javascript
Javascript 是你的高阶函数(高级应用)
2015/06/15 Javascript
jQuery满屏焦点图左右滚动特效代码分享
2015/09/07 Javascript
NODE.JS跨域问题的完美解决方案
2016/10/20 Javascript
[04:04]显微镜下的DOTA2第六期——电影级别的华丽团战
2014/06/20 DOTA
从零学python系列之数据处理编程实例(二)
2014/05/22 Python
Python中除法使用的注意事项
2014/08/21 Python
python在windows命令行下输出彩色文字的方法
2015/03/19 Python
python字典多键值及重复键值的使用方法(详解)
2016/10/31 Python
Python数据结构之栈、队列的实现代码分享
2017/12/04 Python
小白如何入门Python? 制作一个网站为例
2018/03/06 Python
解决phantomjs截图失败,phantom.exit位置的问题
2018/05/17 Python
Centos下实现安装Python3.6和Python2共存
2018/08/15 Python
Python常见的pandas用法demo示例
2019/03/16 Python
YUV转为jpg图像的实现
2019/12/09 Python
纯CSS打造(无图像无js)的非常流行的讲话(语音)气泡效果
2012/12/28 HTML / CSS
用HTML5实现手机摇一摇的功能的教程
2012/10/30 HTML / CSS
美国最大的万圣节服装网站:HalloweenCostumes.com
2017/10/12 全球购物
Hunkemöller瑞士网上商店:欧洲最大的内衣品牌之一
2018/12/03 全球购物
Linux机考试题
2015/07/17 面试题
《石榴》教学反思
2014/03/02 职场文书
殡葬服务心得体会
2014/09/11 职场文书
2014年实习班主任工作总结
2014/11/08 职场文书
办公室主任岗位职责范本
2015/03/31 职场文书
解约证明模板
2015/06/19 职场文书
总结Pyinstaller打包的高级用法
2021/06/28 Python