-3

It recently came to my attention that the agency I work for that the <button> elements are not clickable.

The way the markup is the following:

<button><a href="javascript:void(0)"Text</a></button>

It works fine in all other browsers, but buggy ol' FireFox isn't getting along with it.

Here's the link to the page we discovered it on, try clicking on either in FireFox, and also Chrome. See how it's supposed to behave, but isn't in FF.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
andandandandrew
  • 59
  • 1
  • 11

2 Answers2

1

It doesn't work because <a></a> it's not allowed inside of a Button see the the-button-element documentation, then you can't depend on having the links as a children of the button.

You have to use another element to contain the <a>.

If you want to do some tricks you can do this :

<a href="javascript:void(0)"><button>Text</button></a>

For more information check those answers

Community
  • 1
  • 1
Skizo-ozᴉʞS ツ
  • 19,464
  • 18
  • 81
  • 148
  • If the question is a duplicate, you should be voting to close it as such, not answer it. – cimmanon Feb 18 '16 at 22:43
  • The "duplicate" doesn't use JavaScript... anyways I don't think that's a reason to downvote thoug :). – Skizo-ozᴉʞS ツ Feb 18 '16 at 22:44
  • 1
    So let me get this straight, you think that two problems that have the same exact markup except for the fact that one of them has a little bit of javascript can't possibly be duplicates, even though the answers to both questions are identical? That's the literal meaning of duplicate. And yes, the downvote is entirely warranted: you should not be answering duplicates, *especially* when you know they are duplicates. – cimmanon Feb 18 '16 at 22:52
  • In addition, your solution is illegal too: just like it's not allowed to have an in a – Mr Lister Feb 26 '16 at 09:41
-1

You can not put a <a> within a <button>. I suggest that you change your code to one of the following:

<button onclick="javascript:void(0)">Text</button>

or

<a href="javascript:void(0)">Text</a>