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

  • 2020-05-16 06:23:59
  • OfStack

This example demonstrates how jQuery creates a custom selector to select a hyperlink implementation with a height greater than 100. Share with you for your reference. The specific analysis is as follows:

jQuery creates a custom selector that can actually be a function. The JS code below defines an over100pixels selector to select links with a height greater than 100. This technique is very useful


$.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 has helped you with your jQuery programming.


Related articles: