NiallRedmond NiallRedmond - 3 months ago 16
HTML Question

HTML turn a link into a button

<a href="#">
<div class="col-md-4 promo-item item-1">

I got a template online, the above (with css/bootstrap?), is an image that is a link. I want to change it so that instead of a link (
), it's a clickable button.

My plan is for the button to use JavaScript to change some of the content on the page, basing it off the JavaScript below;

<button type="button" onclick="document.getElementById('demo').innerHTML='Hello JavaScript!' ">
Click Me!

So how do I change this
into a button?


in bootstrap you just add the button classes and it will look like a button

<a class='btn btn-default' ...

However, there is no reason you can't just copy the onclick attribute to the anchor tag (or "href" as you keep calling it).

From your code in the comments:

<div id='demo'></div>

<a onclick="document.getElementById('demo').innerHTML='Hello JavaScript!'; return false; "> Click Me!&gt; <div class="col-md-4 promo-item item-1"> <h3> Unleash </h3> </div> </a>