[英]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.