Jquery:当前元素的属性以开头
jquery中的属性“Start With”非常简单,但我有一个问题 如何对当前元素使用此属性? 例如,我尝试:Jquery:当前元素的属性以开头,jquery,jquery-attributes,Jquery,Jquery Attributes,jquery中的属性“Start With”非常简单,但我有一个问题 如何对当前元素使用此属性? 例如,我尝试: $('this[id^= "PostTypes"]') 及 但是没有什么能起作用。使用 使用 我相信你想要: $('[id^="PostTypes"]', this) 我相信你想要: $('[id^="PostTypes"]', this) 试试看 或者,如果要检查当前元素是否匹配,则可以使用: 例如: if($(this).is('[id^= "PostTypes"]'))
$('this[id^= "PostTypes"]')
及
但是没有什么能起作用。使用
使用
我相信你想要:
$('[id^="PostTypes"]', this)
我相信你想要:
$('[id^="PostTypes"]', this)
试试看
或者,如果要检查当前元素是否匹配,则可以使用:
例如:
if($(this).is('[id^= "PostTypes"]')){
//Current element starts with id PostTypes, do something with it.
}
试试看
或者,如果要检查当前元素是否匹配,则可以使用:
例如:
if($(this).is('[id^= "PostTypes"]')){
//Current element starts with id PostTypes, do something with it.
}
你想说什么do@ArunPJohny我尝试获取当前元素的id,如果它带有“PostTypes”进行一些更改,您想做什么do@ArunPJohny我尝试获取当前元素的id,如果它使用“PostTypes”进行统计,则进行一些更改
$(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.
}