Google [站内搜索]

分类: 脚本语言预览模式: 普通 | 列表

Don’t Use jquery-latest.js[转]

Earlier this week the jQuery CDN had an issue that made the jquery-latest.js and jquery-latest.min.js files unavailable for a few hours in some geographical areas. (This wasn’t a problem with the CDN itself, but with the repository that provides files for the CDN.) While we always hope to have 100% uptime, this particular outage emphasized the number of production sites following the antipattern of using this file. So let’s be clear: Don’t use jquery-latest.js on a production site.

We know that jquery-latest.js is abused because of the CDN statistics showing it’s the most popular file. That wouldn’t be the case if it was only being used by developers to make a local copy. The jquery-latest.js and jquery-latest.min.js files were meant to provide a simple way to download the latest released version of jQuery core. Instead, some developers include this version directly in their production sites, exposing users to the risk of a broken site each time a new version of jQuery is released. The team tries to minimize those risks, of course, but the jQuery ecosystem is so large that we can’t possibly check it all before making a new release.

To mitigate the risk of “breaking the web”, the jQuery team decided back in 2013 that jquery-latest.js could not be upgraded to the 2.0 branch even though that is technically the latest version. There would just be too many sites that would mysteriously stop working with older versions of Internet Explorer, and many of those sites may not be maintained today.

查看更多...

分类:脚本语言 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 20557

jQuery自定义事件添加和触发示例

我们可以用jQuery的on方法在任一对象上添加自定义事件,之后用trigger方法触发自定义事件,代码示例:

<!doctype html>
<html>
    <head>

查看更多...

分类:脚本语言 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 1631
<script src="//code.jquery.com/jquery-3.6.0.min.js"></script>

👉说明:jQuery 2.0以上版本不再支持I 6/7/8,并不是最新的版本就最好的,而是根据您项目需求所适合的版本!

jQuery Core - All 3.x Versions - 不兼容IE6/7/8,只支持最新的浏览器。

查看更多...

分类:脚本语言 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 6003

jQuery对象和DOM对象相互转换示例[转]

jQuery对象是通过jQuery包装DOM对象后产生的对象。jQuery对象是jQuery独有的,其可以使用jQuery里的方法,但是不能使用DOM的方法,例如: $("#img").attr("src","test.jpg"); 这里的 $("#img")就是jQuery对象。

DOM对象是Javascript固有的一些对象。DOM对象能使用Javascript固有的方法,但是不能使用jQuery的方法。例如:document.getElementById("img").src = “test.jpg";这里的document.getElementById("img") 就是DOM对象。

$("#img").attr("src","test.jpg") 和 document.getElementById("img").src = "test.jpg" 是等价的,是正确的,但是 $("#img").src = "test.jpg" 或者 document.getElementById("img").attr("src","test.jpg") 都是错误的。

查看更多...

分类:脚本语言 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 1868

检测浏览器是否支持HTML5



Javascript检测浏览器是否支持HTML5

<script type="text/javascript">

查看更多...

分类:脚本语言 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2424
1.同一页面jQuery多个版本间冲突解决方法

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

查看更多...

分类:脚本语言 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2853

jQuery实现加载提示loading脚本

<style type="text/css">
    #loading{position:fixed;_position:absolute;top:50%;left:50%;width:120px;height:120px;overflow:hidden;background:url(images/loading.gif) no-repeat;z-index:10;display:none;}
</style>

<div id="loading"></div>

查看更多...

分类:脚本语言 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 4232

增强用户体验修改一例

给客户做了一个微信上的订单查询页面,反馈说输入内容时输入框被遮挡住了,用户体验不好:



原因是版权一处设计成浮动的,始终显示在浏览器底部,当输入内容时打开了手机输入法占据了一部分空间,进而使浏览器窗口变小,版权向上浮动导致输入框被遮挡。虽然即便没有被遮挡,若要输入订单号也仍需向上拉动页面,但被遮挡用户体验上终归不好,必须的必须改。

查看更多...

分类:脚本语言 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2790

jQuery判断滚动条滚到页面底部脚本

$(window).scroll(function () {
    if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
        alert("哦哦,到底了.");
    }
});

查看更多...

分类:脚本语言 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 3068

几个另类Javascript遍历数组方法

var a = ["m", "z", "w", "u", "c", "o", "m"];
for (var i = 0, b = a; i < a.length; b = a[++i]) {
    console.log(b);
}

还可以换一种写法:

查看更多...

分类:脚本语言 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2949