Using jQuery selector to search content with filter startswith

Add filter to jQuery

 $.expr[":"].startsWith = function(el, i, m) {
     var search = m[3];
     if (!search) return false;
     return eval("/^[/s]*" + search + "/i").test($(el).text());
 };

Using filter

$('p:startsWith("hello")').text();

Thanks: http://west-wind.com/Weblog/posts/519980.aspx

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA Image

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>