首页 > web前端 > js教程 > 正文

jquery 问答知识整理_jquery

php中文网
发布: 2016-05-16 18:34:44
原创
1531人浏览过

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

clip_image001

解决方案:

CSS to disable resizing

textarea {
resize: none;
}
<textarea <SPAN style="COLOR: #0000ff">name</SPAN>="<SPAN style="COLOR: #8b0000">foo</SPAN>">

textarea[<SPAN style="COLOR: #0000ff">name</SPAN>=foo] {
resize: none;
}

HTML is <textarea id="<SPAN style="COLOR: #8b0000">foo</SPAN>">)

#foo {
resize: none;
}
登录后复制

 

ima.copilot
ima.copilot

腾讯大混元模型推出的智能工作台产品,提供知识库管理、AI问答、智能写作等功能

ima.copilot 386
查看详情 ima.copilot
  • 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置底的提示框

clip_image002

clip_image003

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

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

  • 可编辑的Input

http://acme.com/javascript/

http://code.google.com/p/chromium/issues/detail?id=115230

http://code.google.com/p/chromium/issues/detail?id=115231

  • jQuery与prototype(ajaxpro)冲突的解决方法

http://code.google.com/p/chromium/issues/detail?id=115232

  • 利用jQuery + Handler(ashx) + LINQ 實現 Autocomplete

http://code.google.com/p/chromium/issues/detail?id=115233

  • jquery ajax 中文乱码

http://code.google.com/p/chromium/issues/detail?id=115234

  • Ajax中文乱码原因分析及解决方案

http://code.google.com/p/chromium/issues/detail?id=115235

  • 打造基于jQuery的高性能TreeView

http://code.google.com/p/chromium/issues/detail?id=115236

http://code.google.com/p/chromium/issues/detail?id=115237

  • 利用jQuery实现更简单的Ajax跨域请求

http://code.google.com/p/chromium/issues/detail?id=115238

  • Jquery.Ajax 读取XML
<SPAN style="COLOR: #800000">first</SPAN> <SPAN style="COLOR: #800000">of</SPAN> <SPAN style="COLOR: #800000">all</SPAN> <SPAN style="COLOR: #800000">sorry</SPAN> <SPAN style="COLOR: #800000">about</SPAN> <SPAN style="COLOR: #800000">my</SPAN> <SPAN style="COLOR: #800000">english</SPAN>, <SPAN style="COLOR: #800000">it</SPAN>'<SPAN style="COLOR: #800000">s</SPAN> <SPAN style="COLOR: #800000">not</SPAN> <SPAN style="COLOR: #800000">my</SPAN> <SPAN style="COLOR: #800000">native</SPAN> <SPAN style="COLOR: #800000">lengauge</SPAN>...
<SPAN style="COLOR: #800000">i</SPAN> <SPAN style="COLOR: #800000">have</SPAN> <SPAN style="COLOR: #800000">a</SPAN> <SPAN style="COLOR: #800000">xml</SPAN> <SPAN style="COLOR: #800000">file</SPAN> <SPAN style="COLOR: #800000">that</SPAN> <SPAN style="COLOR: #800000">i</SPAN>'<SPAN style="COLOR: #800000">m</SPAN> <SPAN style="COLOR: #800000">reading</SPAN> <SPAN style="COLOR: #800000">with</SPAN> <SPAN style="COLOR: #800000">the</SPAN> <SPAN style="COLOR: #800000">sample</SPAN> <SPAN style="COLOR: #800000">code</SPAN> <SPAN style="COLOR: #800000">above</SPAN>... 
登录后复制
<SPAN style="COLOR: #800000">but</SPAN> <SPAN style="COLOR: #800000">when</SPAN> <SPAN style="COLOR: #800000">i</SPAN> <SPAN style="COLOR: #800000">try</SPAN> <SPAN style="COLOR: #800000">to</SPAN> <SPAN style="COLOR: #800000">read</SPAN> <SPAN style="COLOR: #800000">it</SPAN> <SPAN style="COLOR: #800000">from</SPAN> <SPAN style="COLOR: #800000">a</SPAN> <SPAN style="COLOR: #800000">service</SPAN> <SPAN style="COLOR: #800000">web</SPAN> <SPAN style="COLOR: #800000">page</SPAN> (<SPAN style="COLOR: #800000"><A href="http://www.google.com/ig/api?weather=Buenos%20A">http</A></SPAN>://<SPAN style="COLOR: #800000">www</SPAN>.<SPAN style="COLOR: #800000">google</SPAN>.<SPAN style="COLOR: #800000">com</SPAN>/<SPAN style="COLOR: #800000">ig</SPAN>/<SPAN style="COLOR: #800000">api</SPAN>?<SPAN style="COLOR: #800000">weather</SPAN>=<SPAN style="COLOR: #800000">Buenos</SPAN>%<SPAN style="COLOR: #800000">20A</SPAN>...), 
登录后复制
<SPAN style="COLOR: #800000">it</SPAN> <SPAN style="COLOR: #800000">doesn</SPAN>'<SPAN style="COLOR: #800000">t</SPAN> <SPAN style="COLOR: #800000">show</SPAN> <SPAN style="COLOR: #800000">anything</SPAN>... <SPAN style="COLOR: #800000">and</SPAN> <SPAN style="COLOR: #800000">if</SPAN> <SPAN style="COLOR: #800000">i</SPAN> <SPAN style="COLOR: #800000">write</SPAN> <SPAN style="COLOR: #800000">the</SPAN> <SPAN style="COLOR: #800000">same</SPAN> <SPAN style="COLOR: #800000">content</SPAN> <SPAN style="COLOR: #800000">of</SPAN> <SPAN style="COLOR: #800000">this</SPAN> <SPAN style="COLOR: #800000">page</SPAN> <SPAN style="COLOR: #800000">in</SPAN> <SPAN style="COLOR: #800000">a</SPAN> <SPAN style="COLOR: #800000">xml</SPAN> <SPAN style="COLOR: #800000">file</SPAN> <SPAN style="COLOR: #800000">in</SPAN> <SPAN style="COLOR: #800000">my</SPAN> <SPAN style="COLOR: #800000">pc</SPAN>, 
登录后复制
<SPAN style="COLOR: #800000">it</SPAN> <SPAN style="COLOR: #800000">works</SPAN> <SPAN style="COLOR: #800000">perfectly</SPAN>... <SPAN style="COLOR: #800000">i</SPAN> <SPAN style="COLOR: #800000">dont</SPAN> <SPAN style="COLOR: #800000">know</SPAN> <SPAN style="COLOR: #800000">what</SPAN> <SPAN style="COLOR: #800000">am</SPAN> <SPAN style="COLOR: #800000">i</SPAN> <SPAN style="COLOR: #800000">doing</SPAN> <SPAN style="COLOR: #800000">wrong</SPAN>
<SPAN style="COLOR: #800000">i</SPAN> <SPAN style="COLOR: #800000">let</SPAN> <SPAN style="COLOR: #800000">u</SPAN> <SPAN style="COLOR: #800000">the</SPAN> <SPAN style="COLOR: #800000">code</SPAN> <SPAN style="COLOR: #800000">that</SPAN> <SPAN style="COLOR: #800000">i</SPAN>'<SPAN style="COLOR: #800000">m</SPAN> <SPAN style="COLOR: #800000">using</SPAN> <SPAN style="COLOR: #800000">maybe</SPAN> <SPAN style="COLOR: #800000">u</SPAN> <SPAN style="COLOR: #800000">could</SPAN> <SPAN style="COLOR: #800000">help</SPAN> <SPAN style="COLOR: #800000">me</SPAN>
<SPAN style="COLOR: #800000">function</SPAN> <SPAN style="COLOR: #800000">clima</SPAN>(){
$.<SPAN style="COLOR: #ff0000">ajax</SPAN>(<SPAN style="COLOR: #0000ff">{
  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)</SPAN>;
  }
 });
}

<SPAN style="COLOR: #800000">function</SPAN> <SPAN style="COLOR: #800000">clima</SPAN>() {
$.<SPAN style="COLOR: #ff0000">ajax</SPAN>(<SPAN style="COLOR: #0000ff">{
  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")</SPAN>;
<SPAN style="COLOR: #ff0000">   alert</SPAN>(<SPAN style="COLOR: #0000ff">"Prognostico para hoy: " + weather + " grados")</SPAN>;
  }
 });
}
登录后复制

 

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

http://code.google.com/p/chromium/issues/detail?id=115239

clip_image0040

clip_image0051

有关于$.ajaxSetup和$.get的问题

在Common.js中使用

  $.ajaxSetup({
    url: "<SPAN style="COLOR: #8b0000">…..</SPAN>",
    type: "<SPAN style="COLOR: #8b0000">POST</SPAN>",
    cache: <SPAN style="COLOR: #0000ff">true</SPAN>,
    dataType: "<SPAN style="COLOR: #8b0000">json</SPAN>"
  });
  $.ajax({
    data: { cityCode: cityCode, flag: flag },
    success: <SPAN style="COLOR: #0000ff">function</SPAN>(areaList) { …}

  });
登录后复制

在PageA页面引入Common.js

   然后在脚本段中使用 $.get(url);

  此处url调用的是一个aspx页面,显示结果为无数据加载!(正常情况:有数据加载。)

  然后经过使用IE8的开发人员工具,进行Trace Error.最终发现原因错误信息(如下)

  "Invalid JSON:

"form1" method="post" action="ajax_select

那么如何解决呢?

原因:

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

解决方案:

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

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

       结果:OK

分析源由:

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

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

image2

最终解决方案:

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

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

    结果:OK

     image3

相关标签:
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号