[英]Jquery : Attribute Start With for current element
jQuery中的“开始于”属性非常简单,但是我有一个问题。如何将此属性用于当前元素? 例如,我尝试过:
$('this[id^= "PostTypes"]')
和
$(this[id^= "PostTypes"])
但是没有想要的东西。
尝试,
$('[id^= "PostTypes"]', this); // if you want to find the elements that are descendants of this.
或者,如果您要检查当前元素是否匹配,则可以使用.is(selector) :
$(this).is('[id^= "PostTypes"]'); //Check if this element is havind the id startswith PostTypes.
例:
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.