Austyn Mitchell Austyn Mitchell - 3 months ago 9
Javascript Question

JavaScript version of this jQuery line

I am searching for a javascript alternative for the following code:


I have never worked with javascript. This may be very simple for someone who's more experienced with javascript.


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*=""]').attr('href') );
console.log( document.querySelector('a[href*=""]').href );
<script src=""></script>
<a href="">one</a>