如何使用jquery选择特定的锚标签?

Muh*_*qan 4 html jquery

你可以看到我有两种类型的锚标签.

第一:

<a>Link</a>
Run Code Online (Sandbox Code Playgroud)

第二个:

<a href="http://facebook.com"></a>
<a href="http://twitter.com"></a>
Run Code Online (Sandbox Code Playgroud)

我只想<a>Link</a>用jquery 选择这种类型的标签.

ian*_*naz 6

$('a').filter(function(){
     return !$(this).attr('href');
});
Run Code Online (Sandbox Code Playgroud)

工作示例:http://jsfiddle.net/3Sczq/


Ell*_*ott 5

你应该使用:notcss选择器:

$('a:not([href])')
Run Code Online (Sandbox Code Playgroud)

选择a没有属性的所有标签href

jQuery文档在这里