문제

Is it possible to have a jQuery selector where the :contains() is a regular expression?

I need to select an element where the innerHTML contains something findable through regex?

I know it's a short question. My apologies.

var t = $("#id a:containsRegex("/[0-9]/g")"); // Doesn't work
도움이 되었습니까?

해결책

Try ,

var regex = new RegExp("[0-9]"); // expression here

$("#id a").filter(function () {
    return regex.test($(this).text()); 
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top