0

Im trying to make a logout button using a javascript onlick event but I have a syntax error.

<button type="button" tabindex="0" class="dropdown-item" onclick="window.location.href = '/index.php?logout='1'';">Logout</button>

When I implement the link like this is works but this is not the desired implementation as its using a hyperlink instead of the button.

<button type="button" tabindex="0" class="dropdown-item"><a href="/index.php?logout='1'" title="Sign Out">Logout</a></button>

Apologies for the newb question in advance. New at JS :)

jt251
  • 1
  • Better option: avoid inline handlers entirely so you don't have to mess with silly escaping issues like these. (there are [many other](https://stackoverflow.com/a/59539045) reasons to avoid inline handlers as well) – CertainPerformance Mar 02 '20 at 02:32
  • The escaping method is working for now I will look into how to avoid inline handlers. Thanks for the help @CertainPerformance – jt251 Mar 02 '20 at 03:33

0 Answers0