Skip to content Skip to sidebar Skip to footer

Trailing Slash Remove In Www.mysite.com/#i-bc

I want to go to a particular div on my home page itself when select on change event. I want result like www.mysite.com#i-bc but trailing slash added in between them like www.mysite

Solution 1:

Try this,

$(function(){
    $('.toggle-view').on('change', function () {
        var url = $(this).val();
        if (url) {
           window.location.hash = url;
        }
        returnfalse;
    });
});

window.location.hash is specifically used to play with hashed urls.

Solution 2:

Better use window.location.hash. Its better than href

<script>
    $(function(){
      $('.toggle-view').on('change', function () {
          var url = $(this).val();
          if (url) {
              window.location.hash = url;
                    }
          returnfalse;
      });
    });
 </script>

Post a Comment for "Trailing Slash Remove In Www.mysite.com/#i-bc"