masteringprojects masteringprojects - 1 year ago 41
HTML Question

a href link that will act like a button

Is there any clean method to make a regular link :

<a href="[8]">Click here to read more...</a>

to act EXACTLY like a button

<button id="[8]">Click here to read more...</button>

Thanks !

Answer Source

Do you mean something like this?

<a id="[8]" class="readmore" href="#">
    Click here to

Adapting your javascript to the new "a":

$("a.readmore").click(function() { 
    var d_id=id[1].split(']'); 
    var ii=d_id[0] $('html, body').animate({ 
       scrollTop: $('[id='+ii+']').offset().top 
    }, 2000); 

    return false;

Just a tip, your string processing looks terrible, suggestion:

$("a.readmore").click(function() { 

    $('html, body').animate({ 
       scrollTop: $('[id='+ id +']').offset().top 
    }, 2000); 

    return false;

Ensure this code is being intercept by the page dom parser in the right time, put it inside a

$(document).ready(function(){ ... });