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 !
Do you mean something like this?
<a id="[8]" class="readmore" href="#">
Click here to read more...
</a>
Adapting your javascript to the new "a":
$("a.readmore").click(function() {
var id=this.id.split('[');
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() {
var id=this.id.match('[0-9]+');
$('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(){ ... });
Regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With