Home > Web Front-end > JS Tutorial > body text

jQuery创建自定义的选择器用以选择高度大于100的超链接实例_jquery

WBOY
Release: 2016-05-16 16:08:56
Original
1194 people have browsed it

本文实例讲述了jQuery创建自定义的选择器用以选择高度大于100的超链接实现方法。分享给大家供大家参考。具体分析如下:

jQuery创建一个自定义的选择器,自己定义的这个选择器实际上可以是一个函数,下面的JS代码定义了一个over100pixels的选择器,选择出高度大于100的链接,这类技巧非常实用

$.extend($.expr[':'], {
  over100pixels: function(a) {
    return $(a).height() > 100;
  }
});
$('.box:over100pixels').click(function() {
  alert('The element you clicked is over 100 pixels high');
});
Copy after login

希望本文所述对大家的jQuery程序设计有所帮助。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!