skip to Main Content
document.getElementById("myproject-2").onclick=functio{
 location.href="https://aruneet-11.github.io/drumKit/";
}

used this code to go to that link when we click on the button but it’s not redirceting to the page.Nothing happens when I click on the button and I have included the script file before the closing body tag.

I am expecting whenever I click on the button then It will open that link.

2

Answers


  1. There are some syntax errors in your code

    Try the following

    document.getElementById("myproject-2").onclick = function () {
      window.location.href = "https://aruneet-11.github.io/drumKit/";
    };
    
    Login or Signup to reply.
  2. Please correct your syntax after onclick= add function() and then continue with {

    It will solve your problem.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search