If you are specifically looking for href
values ββthat have empty values, follow these steps
$('a[href=""]').each(function() { $(a).attr('href', 'theNewUrl'); });
This will only capture anchor tags that have an href attribute that is empty. This will not work though for anchors that lack the href tag
<a href="">Link 1</a> <a>Link 2</a>
If you need to combine the latter, follow these steps
$('a').each(function() { var href = $(this).attr('href') || ''; if (href === '') { $(this).attr('href', 'theNewUrl'); } });
source share