[英]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? jQuery中的“开始于”属性非常简单,但是我有一个问题。如何将此属性用于当前元素? As example i tried:
例如,我尝试过:
$('this[id^= "PostTypes"]')
AND 和
$(this[id^= "PostTypes"])
But nothing want works. 但是没有想要的东西。
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) : 或者,如果您要检查当前元素是否匹配,则可以使用.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.
}
使用filter()
$(this).filter('[id^= "PostTypes"]')
我相信你想要:
$('[id^="PostTypes"]', this)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.