Jump to content

Creating buttons that link to different pages

Recommended Posts

Site URL: https://shuvamkabir.net

I'm trying to add buttons that link to other pages on my website, using jquery and

$('.button').click(function() {
   window.location.href = "https://www.shuvamkabir.net/someotherpage";}) 

However, the links don't appear to work. Clicking does nothing. I'm not sure what I'm doing wrong here. I've included the code for the buttons that I'm using.

<style>
/**/
/*Main Navigation Buttons*/
/**/
.navbuttonsection{
    /*text-align: right;*/
    /*display:none;border-radius:6px;*/
    width:350px;
    /*height:300px;margin:auto;box-sizing:border-box;padding-bottom:35px;*/
    /*z-index: 1;*/
    position: absolute;
    right: 0%;
    /*margin-right: -80px;*/ 
    /*bottom: 25px*/
  }
  .button-nav{
    text-transform:uppercase;
    text-align: right;
    font-size:1.1em;
    letter-spacing:.2em;
    box-sizing:border-box;
    vertical-align:middle;
    width:350px;
    height:50px;
    opacity: 0.5;
    transition: opacity .6s ease-in-out, width .6s ease-in-out, right .6s ease-in-out, left .6s ease-in-out, letter-spacing .6s ease-in-out;   
    border-top-left-radius:10px;
    border-bottom-left-radius:10px;
    border-top-right-radius:10px;
    border-bottom-right-radius:10px;
    background-color: white;
    color: black
  }
  .button-nav:hover{
    opacity: 0.8;
    width:100%;
    left: 10%;
    letter-spacing: .3em;
  }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
/**/
/*Navigation button functionality*/
/**/
/*$('.button-nav').click(function() {
   window.location = "https://www.shuvamkabir.net/" + this.id;
});*/
$('.button-Experience').click(function() {
   window.location.href = "https://www.shuvamkabir.net/experience"
});
$('.button-Portfolio').click(function() {
   window.location.href = "https://www.shuvamkabir.net/portfolio";
});
$('.button-CV').click(function() {
   window.location.href = "https://www.shuvamkabir.net/pageCV";
});
$('.button-Services').click(function() {
   window.location.href = "https://www.shuvamkabir.net/services";
});
</script>

 

Link to comment
  • Replies 1
  • Views 346
  • Created
  • Last Reply
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
jQuery(document).ready(function($) {
      /**/
  /*Navigation button functionality*/
  /**/
  /*$('.button-nav').click(function() {
     window.location = "https://www.shuvamkabir.net/" + this.id;
  });*/
  $('.button-Experience').click(function() {
     window.location.href = "https://www.shuvamkabir.net/experience"
  });
  $('.button-Portfolio').click(function() {
     window.location.href = "https://www.shuvamkabir.net/portfolio";
  });
  $('.button-CV').click(function() {
     window.location.href = "https://www.shuvamkabir.net/pageCV";
  });
  $('.button-Services').click(function() {
     window.location.href = "https://www.shuvamkabir.net/services";
  });
});
</script>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.