Muhammad Furqan
Muhammad Furqan

Reputation: 324

How can i select specific anchor tag using jquery?

i have two types of anchor tag as you can see.

First :

<a>Link</a>

and Second :

<a href="http://facebook.com"></a>
<a href="http://twitter.com"></a>

i just want to select only this type tags <a>Link</a> using jquery.

Upvotes: 4

Views: 2437

Answers (2)

Elliott
Elliott

Reputation: 2729

You should use the :not css selector:

$('a:not([href])')

Select all a tags without an attribute href

jQuery docs here

Upvotes: 5

ianaz
ianaz

Reputation: 2590

$('a').filter(function(){
     return !$(this).attr('href');
});

Working example: http://jsfiddle.net/3Sczq/

Upvotes: 6

Related Questions