Reputation: 11
I'm trying to check if a link already exists by it href property in a HTML document before to add another one.
The code is just like:
if (!$('a[href*="#businessInfoMenu"]')){
//add new link
}
Does anyone made something like that?
Thanks in advance,
Upvotes: 0
Views: 1712
Reputation: 63512
You can check the length
of the selector to see if there were any matches:
if ($('a[href*="#businessInfoMenu"]').length == 0) {
//add new link
}
Upvotes: 3