Jquery检查图像是否具有title属性

Jquery检查图像是否具有title属性,jquery,if-statement,attributes,image,title,Jquery,If Statement,Attributes,Image,Title,如何检查img标签是否具有title属性 就像在这个伪代码中: IF image has a tile attribute THEN DO Something 您只需执行以下操作: if ($('#selection').attr('title')){ alert('YAY 4 TITLES'); } 您只需执行以下操作: if ($('#selection').attr('title')){ alert('YAY 4 TITLES'); } 希望有帮助:) 搜索图像时,您也可以只包含

如何检查img标签是否具有title属性

就像在这个伪代码中:

IF image has a tile attribute THEN 

DO Something
您只需执行以下操作:

if ($('#selection').attr('title')){
alert('YAY 4 TITLES');
}
您只需执行以下操作:

if ($('#selection').attr('title')){
alert('YAY 4 TITLES');
}
希望有帮助:)

搜索图像时,您也可以只包含
[title]
属性

alert($("#idOfYourImage[title]").length > 0);
希望有帮助:)

搜索图像时,您也可以只包含
[title]
属性

alert($("#idOfYourImage[title]").length > 0);
像这样,我的朋友:

if($('element').attr('title')){
  // do something
}
像这样,我的朋友:

if($('element').attr('title')){
  // do something
}
这样就可以了:)

我最喜欢这样,所以当有人问一些简单的问题时,所有的答案都涌了进来

这样就可以了:)

我最喜欢这样,所以当有人问一些简单的问题时,所有的答案都涌了进来

如果img标签有title属性

为您的
img
标记一个id

if($("#imgID").is("[title]")){
 //your code here
}
要从所有标题为
attr
img
标签中选择
img
标签,您可以使用 下面的代码将过滤掉所有具有attr标题的img标记并隐藏它们,您可以根据需要进行修改

$("img").filter(function(){return $(this).is("[title]")}).hide();
如果img标签有title属性

为您的
img
标记一个id

if($("#imgID").is("[title]")){
 //your code here
}
要从所有标题为
attr
img
标签中选择
img
标签,您可以使用 下面的代码将过滤掉所有具有attr标题的img标记并隐藏它们,您可以根据需要进行修改

$("img").filter(function(){return $(this).is("[title]")}).hide();

该死的,比我快5秒!该死的,比我快5秒!或者,您可以只编写
$(“img[title]”)。hide()或者,您可以只编写
$(“img[title]”)。hide()