I'm trying to create an if else in jquery with attr (), I want the if else to check if <a href="google.com" class="test" title="test">
exists and if it exists change the href value to another url, for example youtube.com
I got to create an attr () but without if else that worked that model below:
jQuery (document) .ready (function () {
jQuery ('a.test [title = "test"]'). attr ('href', 'google.com');
})
But I don't want it that way, I want him to take the test first, whether it exists or not.
How can I do this using the jQuery if-else
?