开发者

How to evaluate the following expression in jQuery without eval()?

开发者 https://www.devze.com 2023-03-16 15:08 出处:网络
I have the following code that does开发者_如何学运维n\'t seem to be OK in context of jQuery: jQuery.expr[ \":\" ].containsNoCase = function( el, i, m ) {

I have the following code that does开发者_如何学运维n't seem to be OK in context of jQuery:

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

Is there any other way to return result?


I believe you want

new RegExp(search, "i").test(jQuery(el).text());
0

精彩评论

暂无评论...
验证码 换一张
取 消