jQuery提示和技巧 [英] jQuery Tips and Tricks
本文介绍了jQuery提示和技巧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 准备事件的简写由roosteronacid提供
- roosteronacid的换行符和可链接性
- 嵌套过滤器作者:Nathan Long
- 通过roosteronacid缓存集合并在同一行执行命令
- 由roosteronacid包含选择器
- 在元素创建时定义属性由roosteronacid
- 按照roosteronacid的方式访问jQuery函数
- noConflict函数 - 释放$变量由Oli
- 通过nickf 在noConflict模式下隔离$变量 / li>
- 通过roosteronacid 无冲突模式
- Shorthand for the ready-event by roosteronacid
- Line breaks and chainability by roosteronacid
- Nesting filters by Nathan Long
- Cache a collection and execute commands on the same line by roosteronacid
- Contains selector by roosteronacid
- Defining properties at element creation by roosteronacid
- Access jQuery functions as you would an array by roosteronacid
- The noConflict function - Freeing up the $ variable by Oli
- Isolate the $ variable in noConflict mode by nickf
- No-conflict mode by roosteronacid
- 数据功能 - 通过TenebrousX将数据绑定到元素
- HTML5数据属性支持,关于类固醇!由roo steronacid
- jQuery元数据插件 byFilipDupanović
- The data function - bind data to elements by TenebrousX
- HTML5 data attributes support, on steroids! by roosteronacid
- The jQuery metadata plug-in by Filip Dupanović
- 通过roosteronacid优化复杂选择器的性能
- lupefiasco 上下文参数
- Nathan Long 保存并重复使用搜索
- 创建HTML元素并保留引用,检查元素是否存在,编写自己的选择器作者:Andreas Grech
- Optimize performance of complex selectors by roosteronacid
- The context parameter by lupefiasco
- Save and reuse searches by Nathan Long
- Creating an HTML Element and keeping a reference, Checking if an element exists, Writing your own selectors by Andreas Grech
- <小时ef =https://stackoverflow.com/questions/182630/jquery-tips-and-tricks/389906#389906>通过redsquare检查集合中元素的索引
- TM $ b $ 直播活动处理程序 b
- 用命名函数替换匿名函数 by ken
- 由Slace Microsoft AJAX框架和jQuery桥 / li>
- egyamado的 jQuery教程
- 从集合中删除元素并保持可链接性 by roosteronacid
- 在Ben的匿名函数开始时声明$ this
- FireBug lite,Hotbox插件,告知何时加载图像和Google CDN by Color Blend
- harriyott 明智地使用第三方jQuery脚本
- Jan Zich的每项功能 / li>
- 表单扩展插件 Chris S
- 异步每项功能 by OneNerd
- jQuery模板插件:使用渲染函数实现复杂逻辑 by roosteronacid
- Check the index of an element in a collection by redsquare
- Live event handlers by TM
- Replace anonymous functions with named functions by ken
- Microsoft AJAX framework and jQuery bridge by Slace
- jQuery tutorials by egyamado
- Remove elements from a collection and preserve chainability by roosteronacid
- Declare $this at the beginning of anonymous functions by Ben
- FireBug lite, Hotbox plug-in, tell when an image has been loaded and Google CDN by Colour Blend
- Judicious use of third-party jQuery scripts by harriyott
- The each function by Jan Zich
- Form Extensions plug-in by Chris S
- Asynchronous each function by OneNerd
- The jQuery template plug-in: implementing complex logic using render-functions by roosteronacid
推荐答案
创建HTML元素并保留引用
var newDiv = $("<div />");
newDiv.attr("id", "myNewDiv").appendTo("body");
/* Now whenever I want to append the new div I created,
I can just reference it from the "newDiv" variable */
检查元素是否存在
if ($("#someDiv").length)
{
// It exists...
}
编写自己的选择器
$.extend($.expr[":"], {
over100pixels: function (e)
{
return $(e).height() > 100;
}
});
$(".box:over100pixels").click(function ()
{
alert("The element you clicked is over 100 pixels height");
});
这篇关于jQuery提示和技巧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文