user2167382
user2167382

Reputation: 346

Jquery : Attribute Start With for current element

Attribute "Start With" in jquery is very simple, but i have a problem How use this attribute for current element? As example i tried:

$('this[id^= "PostTypes"]') 

AND

$(this[id^= "PostTypes"])

But nothing want works.

Upvotes: 0

Views: 894

Answers (3)

PSL
PSL

Reputation: 123739

Try,

 $('[id^= "PostTypes"]', this); // if you want to find the elements that are descendants of this.

Or if you want to check if the current element is a match then you can use .is(selector):

$(this).is('[id^= "PostTypes"]'); //Check if this element is havind the id startswith PostTypes.

Example:

if($(this).is('[id^= "PostTypes"]')){
   //Current element starts with id PostTypes, do something with it.
}

Upvotes: 4

tymeJV
tymeJV

Reputation: 104775

I believe you want:

$('[id^="PostTypes"]', this)

Upvotes: 0

Arun P Johny
Arun P Johny

Reputation: 388316

Use filter()

$(this).filter('[id^= "PostTypes"]')

Upvotes: 0

Related Questions