Home  >  Article  >  Web Front-end  >  jQuery creates a custom selector to select hyperlink instances with a height greater than 100_jquery

jQuery creates a custom selector to select hyperlink instances with a height greater than 100_jquery

WBOY
WBOYOriginal
2016-05-16 16:08:561226browse

The example in this article describes how jQuery creates a custom selector to select hyperlinks with a height greater than 100. Share it with everyone for your reference. The specific analysis is as follows:

jQuery creates a custom selector. The selector you define can actually be a function. The following JS code defines an over100pixels selector to select links with a height greater than 100. This type of technique is very practical.

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

I hope this article will be helpful to everyone’s jQuery programming.

Statement:
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