2

I used following accordion code, But my page reload or refresh when i click it.

<body>
<h2>IT Teams</h2>
<p>Click on the buttons to open the collapsible content.</p>
<button class="accordion">USA</button>
<div class="panel">
<p>Jose Andrew</p> 
  <p>Edward Gee</p>   
</div>

enter image description here

  • 2
    Doesn't seem to be anything is the script that is causing the reload. Can you share the markup for the "accordion" that they are clicking on? – Rothrock Jul 13 '18 at 17:15
  • Sure , I attached it. – Jen Jul 16 '18 at 14:10
5

Add type="button" to your <button> tag to stop the reload:

<button class="accordion" type="button">

  • 2
    Some more information, as the answer is a bit short: As per w3.org/TR/2011/WD-html5-20110525/… the default type of a button element is the "submit" state (like if specified as <button type="submit" />), which will submit the current form. The type "button" defaults to doing nothing. – Anon Jul 16 '18 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.