How to check if a custom (pseudo) selector has been added to jQuery -


i grabbed following snippet comments on this post @ csstricks.com.

$.extend($.expr[":"], {     "containsnc": function(elem, i, match, array) {         return (elem.textcontent || elem.innertext || "").tolowercase().indexof((match[3] || "").tolowercase()) >= 0;     } }); 

essentially, provides pseudo-selector :containsnc, works :contains case-insensitive.

i want able detect if selector available can conditionally use :contains fallback.

how can check presence of such custom selector?

alternatively, there better way case insensitive matching in newer jquery?

for reference, here's how i'm using :contains (to filter list of facebook friends)

$('#friend-search').on('keyup', 'input', function() {     var $search = $(this).val(),         $friends = $('.friend'),         match = ':contains(' + $search + ')';     $friends.hide().filter(match).show(); }); 

after posting question, did poking around, , found response quite easily:

var containsnc_isdefined = typeof $.expr[":"].containsnc === "function"; if (containsnc_isdefined) alert(":containsnc exists!");  

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -