5

Hi I would like to know how bootstrap can add role="button" to there a href link.

<a href="" role="button">

I can not see the role button anywhere in the css

I am trying to make my own version.

  • 1
    In addition to Jake's answer below, here's some info on what `role` does. http://stackoverflow.com/questions/10403138/role-attribute-in-html – Jorg Apr 07 '14 at 02:09

1 Answers1

5

What exactly do you want the link/button to do?

If you are just looking at styling the link to look like a bootstrap button you can just add the button classes to it:

<a href="#" class="btn btn-primary">A Link</a>

if you want it to function like a button (ie submit a form or something) then you will need javascript or jQuery would be better in order to do that:

    <a href="#" id="myButton">A Link</a>
    <script>
    $(document).ready(function(){
        $("#myButton").click(function(){
            $("#myFormID").submit();
        }); 
    });
    </script>

Then just combine the two and the anchor link will appear and act like a button.

Jake
  • 1,207
  • 2
  • 28
  • 46
  • Thank you ! The "href" attribute is really important else nothing will happen when you hit the "Enter" key. To use keyboard navigation with tabindex="0"... – François Breton Jan 16 '16 at 20:14