Making a <button> that's a link in HTML

前端 未结 7 1240
野的像风
野的像风 2020-12-09 08:49

Basically, I like the way that is styled, with the clickable button when you add a little CSS. However, regular buttons are not st

7条回答
  •  Happy的楠姐
    2020-12-09 09:27

    The 3 easiest ways IMHO are

    1: you create an image of a button and put a href around it. (Not a good way, you lose flexibility and will provide a lot of difficulties and problems.)

    2 (The easiest one) -> JQuery

    
    
      $('button[type=submit] .default').click(function(){
         window.location = $(this).attr("someattribute");
         return false; //otherwise it will send a button submit to the server
    
       });  
    

    3 (also easy but I prefer previous one):

    
    
    $fn.somefunction= function(url) {
        window.location = url;
    };
    

提交回复
热议问题