开发者

check element has a class starting with string using jquery

I am getting the last element from a form which has a value like this:

var lastOne =$(':text[name^=distanceSlab][value!=""]'开发者_高级运维).last();

now I want to find the element which has a class that begins with the string "limit". I have tried something like:

if(lastOne.is("class^='limit'")){
    console.log('BEGINNING WITH LIMIT')
}

but it didn't work. How do I do this?


if(lastOne.is("[class^='limit']")){
    console.log('BEGINNING WITH LIMIT');
}

You forgot to put [] around the selector.


if(lastOne.attr('class').match(/^limit.+/)) ...
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜