Austyn Mitchell Austyn Mitchell - 1 month ago 5
Javascript Question

Searching for a alternative of jquery code [Probably Easy]

iam searching for a javascript alternative for the following code

$('a[href*="vivo.sx/"]').attr('href')


Iam never worked with javascript, so it is probably very easy for a good scripter.
Thanks for reading this and for the Answers.

Answer

I've done a version that does it both way for comparison..

Please note I've used document.querySelector, not document.querySelectorAll, if you use the All variant, remember you need to loop the result.

console.log( $('a[href*="vivo.sx/"]').attr('href') );
console.log( document.querySelector('a[href*="vivo.sx/"]').href );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="http://www.vivo.sx/tester">one</a>