title: javascript preventDefault doesn't work
body: <p>In my new order view I have:</p>
  
  <pre><code>&lt;a id="showhidetrigger1" class='btn btn-primary' 
              onclick="clicked('showhidetarget1');"&gt;&lt;%= current_user.titles[0] %&gt;&lt;/a&gt;
  
  &lt;a id="showhidetrigger2" class='btn btn-primary'
              onclick="clicked('showhidetarget2');"&gt;&lt;%= current_user.titles[2] %&gt;&lt;/a&gt;
  
  &lt;a id="showhidetrigger3" class='btn btn-primary'
              onclick="clicked('showhidetarget3');"&gt;&lt;%= current_user.titles[1] %&gt;&lt;/a&gt;
  
  &lt;div id="showhidetarget1" class='center'&gt;
      &lt;p&gt;&lt;%= render :partial =&gt; "productstype", 
                    :locals =&gt; {:selectedproduct =&gt; @current.bottles, :title =&gt; @current.titles[0] } %&gt;
      &lt;/p&gt; 
  &lt;/div&gt;
  
  &lt;div id="showhidetarget2" class='center'&gt;
      &lt;p&gt;&lt;%= render :partial =&gt; "productstype", 
                    :locals =&gt; {:selectedproduct =&gt; @current.pourings, :title =&gt; @current.titles[2] } %&gt;
      &lt;/p&gt;
  &lt;/div&gt;
  
  &lt;div id="showhidetarget3" class='center'&gt;
      &lt;p&gt;&lt;%= render :partial =&gt; "productstype", 
                    :locals =&gt; {:selectedproduct =&gt; @current.cocktails, :title =&gt; @current.titles[1] } %&gt;
      &lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and in order.js I have:</p>
  
  <pre><code>$(document).ready(function () {
  
  
      hideall = function() {
          $('#showhidetarget1').hide();
          $('#showhidetarget2').hide();
          $('#showhidetarget3').hide();
      };
  
      hideall();
  
      window.clicked = function(item) {
  
          hideall();
          event = event || window.event;
          event.preventDefault();
          event.stopPropagation();
          $('#' + item).toggle(400);
          return false;
      };    
  
  });
  </code></pre>
  
  <p>Hide/show works fine but I can't avoid scrolling on top when buttons are clicked.
  I already tried several solution (<a href="https://stackoverflow.com/questions/31171076/preventdefault-doesnt-work">like these</a> and others on stack) but none worked.</p>
  
  <p>Edit: solved using jquery as suggested... <a href="https://stackoverflow.com/questions/6967081/show-hide-multiple-divs-with-jquery">this</a> Thanks to everyone!!!
  So my jquery function is:</p>
  
  <pre><code>jQuery(function(){
          jQuery('.targetDiv').hide();
          jQuery('.showSingle').click(function(){
                jQuery('.targetDiv').hide();
                jQuery('#div'+$(this).attr('target')).show();
          });
  });
  </code></pre>