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.+/)) ...
精彩评论