Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to Fix Javascript Code for Getting Href Content of a Link

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 580
    Answer it

    I am trying to get the href content of a link that i click on with the class of sessionBtn.


    Here is my code: 

    $('.sessionBtn').on('click', function (e) {

     var url_string  =  document.getElementsByClassName("sessionBtn").href;

     document.getElementById("demo").innerHTML = "document id: "+url_string;



    But i got an error of undefined.

    But when i get the elements by ID it works. 

 1 Answer(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: