2

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?

2 Answers 2

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

You forgot to put [] around the selector.

Sign up to request clarification or add additional context in comments.

1 Comment

How to check class name not starts with string "limit"??
1
if(lastOne.attr('class').match(/^limit.+/)) ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.