get the href value using jquery

this uses the jquery attr function to get the value of the href. this example targets the first a in the card div, so running the demo should alert you with
Rather than using alert in this example, i use sweet alert 2! looks pretty sweet :P


<div class='mydiv'>
<a href='' class='btn btn-primary mb-3'>The Link</a>
<button onclick='getHREF();' class='btn btn-primary mb-3'>Get HREF</button>


function getHREF() {
var the_href = $('.mydiv a').attr('href');;

Page Views

This page has been viewed 195 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
I believe that success can be measured in the number of uncomfortable conversations you're willing to have.