Question

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.

Was it helpful?

Solution

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.
}

OTHER TIPS

Use filter()

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

I believe you want:

$('[id^="PostTypes"]', this)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top