Mantas Jonaitis Mantas Jonaitis - 3 months ago 25
Javascript Question

How to change specific href without having ID or name?

This is all I have. Is there any way to change href?

<a style="color: #0C82FD;" target="_blank" href=""></a>


You can use the attribute selector (by the way, href doesn't pre-suppose a protocol, so adding http:// is worthwhile):

<a style="color: #0C82FD;" target="_blank" href=""></a>

And then changing the href using prop():

$('a[href=""]').prop('href', '');

This of course assumes you don't have other <a> elements with the same href attribute value. If you do, you can then use index() to filter them down.