Create custom selector using jQuery

Today i came to know one very advanced jQuery Concept.
jQuery has its selectors inbuilt. here you can create your own custom selector.
In below code i have given name ‘myCustomSelector’ to my custom selector.
All we need to do is to define it and to give an expression that returns true or false.

  • 5th Line : jQuery.extend is used to extend jQuery to create plugins but in this example it is used to extend jQuery’s ‘:’ expression.
  • 6th Line : a is an object which represents the current element.It is similar to this in other expressions.

Run demo
Have a look at code below.

<script type="text/javascript" src=""></script>
jQuery.extend(jQuery.expr[‘:’], {
myCustomSelector : function (a){
return jQuery(a).html() == ‘Akash’;
jQuery(document).ready(function() {
<table border="1">