Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery:当前元素的属性以开头_Jquery_Jquery Attributes - Fatal编程技术网

Jquery:当前元素的属性以开头

Jquery:当前元素的属性以开头,jquery,jquery-attributes,Jquery,Jquery Attributes,jquery中的属性“Start With”非常简单,但我有一个问题 如何对当前元素使用此属性? 例如,我尝试: $('this[id^= "PostTypes"]') 及 但是没有什么能起作用。使用 使用 我相信你想要: $('[id^="PostTypes"]', this) 我相信你想要: $('[id^="PostTypes"]', this) 试试看 或者,如果要检查当前元素是否匹配,则可以使用: 例如: if($(this).is('[id^= "PostTypes"]'))

jquery中的属性“Start With”非常简单,但我有一个问题 如何对当前元素使用此属性? 例如,我尝试:

$('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.
}