<p>In jQuery, how do you select the <code>&lt;a&gt;</code> which href is pointing to the current URL</p>

<p>For example:<br>
URL = <a href="http://server/dir/script.aspx?id=1" rel="nofollow noreferrer">http://server/dir/script.aspx?id=1</a></p>

<p>I want to select this <code>&lt;a&gt;</code><br>
<code>&lt;a href="/dir/script.aspx"&gt;...&lt;/a&gt;</code></p>

<p>I tried this but it doesn't work:</p>

<pre><code>var url = window.location.href;
$('#ulTopMenu a["'+url+'"*=href]').addClass("selected");
</code></pre>

<p>Probably wrong syntax. Anyone know the right way of doing it?</p>

<p>Thanks in advance</p>

I do not know the answer to your question but is that selector syntax valid?
```
```
'#ulTopMenu a["http://www.foo.com"*=href]'
```
```
I'd imagine if such a thing is possible it'd be written as
```
```
'#ulTopMenu a[href*="http://www.foo.com"]'
```
```